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} \; +