From 0973359ea336a5e47615a2967fadb6e25deb36d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Sat, 21 Oct 2023 21:01:51 +0200 Subject: [PATCH] update github action Former-commit-id: 909a8999745388e1efc6a0087d8f1d2cb339b54f [formerly 9bcc5c7d966659b56d80cab610d687b408b531a3] [formerly 708ea0512cfa490eaa9fafa1f92ea16bdc21cf05 [formerly e05dcfca80571c20cee55718528997e65c8c6110]] Former-commit-id: 21cec496e03f2289531cc5cb20f3b72b8e5b982e [formerly 24e36e46cb412e2743754908cf01ac6c9f88a5db] Former-commit-id: cb9af7fe2caffdc2d6c83a14b7c34eb5ef63e2aa Former-commit-id: 0542a1b9531595d1084c2f70c830d536f84cb0b0 Former-commit-id: 63bb8b12a848a54da8939ab9fcc550de116d77ce Former-commit-id: d139330add70fde1ad06f12c0076b469f20f12e8 [formerly d68fa5332df916927236e4ebd71db495dce065df] Former-commit-id: 6add272957a89d43f310f44c70b17ca2cecd927a --- .github/workflows/release.yaml | 43 +++++++++++----------------------- .goreleaser.yaml | 35 +++++++++++++++++++++++++++ .goreleaser_hook.sh | 27 +++++++++++++++++++++ 3 files changed, 76 insertions(+), 29 deletions(-) create mode 100644 .goreleaser.yaml create mode 100755 .goreleaser_hook.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6d8b551..63fa909 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -110,37 +110,22 @@ jobs: - name: Checkout Git repo uses: actions/checkout@v3 - # Download all artifacts in zip format - # https://github.com/actions/download-artifact/issues/143 - - name: Download artifacts - uses: actions/github-script@v6 + # Download all artifacts + - uses: actions/download-artifact@v3 with: - script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - for (const artifact of allArtifacts.data.artifacts) - { - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: artifact.id, - archive_format: 'zip', - }); - - let fs = require('fs'); - fs.mkdirSync('artifacts'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/artifacts/${artifact.name}.zip`, Buffer.from(download.data)); - } + path: artifacts - name: list artifacts run: find artifacts/ - - - uses: "marvinpinto/action-automatic-releases@latest" + + - name: Set up Go + uses: actions/setup-go@v4 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 with: - repo_token: "${{ secrets.RELEASE_TOKEN }}" - prerelease: true - files: | - artifacts/* + distribution: goreleaser + version: latest + args: release --clean --skip=validate + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..fbff75d --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,35 @@ +builds: + - goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + - arm + goarm: + - "7" + binary: wstunnel + ignore: + - goos: windows + goarch: arm64 + - goos: windows + goarch: arm + - goos: darwin + goarch: arm64 + - goos: darwin + goarch: arm + main: goreleaser.go + hooks: + pre: + - /bin/sh -c "if [ ! -e ./goreleaser.go ]; then echo -e 'package main\\\nfunc main() { }' > ./goreleaser.go ; fi" + post: + - ./.goreleaser_hook.sh {{ .Arch }} {{ .Os }} {{ .ProjectName }} +checksum: + name_template: "checksums.txt" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/.goreleaser_hook.sh b/.goreleaser_hook.sh new file mode 100755 index 0000000..4fce11e --- /dev/null +++ b/.goreleaser_hook.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +go_arch=$1 +go_os=$2 +project_name=$3 + +# Make Go -> Rust arch/os mapping +case $go_arch in + amd64) rust_arch='x86_64' ;; + arm64) rust_arch='aarch64' ;; + arm) rust_arch='armv7' ;; + *) echo "unknown arch: $go_arch" && exit 1 ;; +esac +case $go_os in + linux) rust_os='linux' ;; + darwin) rust_os='apple-darwin' ;; + windows) rust_os='windows' ;; + *) echo "unknown os: $go_os" && exit 1 ;; +esac + +# Find artifacts and uncompress in the coresponding directory +DIST_DIR=$(find dist -type d -name "*${go_os}_${go_arch}*") +echo "DIST_DIR: $DIST_DIR" +rm -rf ${DIST_DIR}/* + +find artifacts -type f -wholename "*${rust_arch}*${rust_os}*" -exec cp {} ${DIST_DIR} \; +