diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..77edc06 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + tag: + description: 'Release tag (e.g. v1.2.3). If empty, uses current ref name.' + required: false + type: string + +permissions: + contents: write + +jobs: + build-and-package: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Install packaging tools + run: | + sudo apt-get update + sudo apt-get install -y zip + + - name: Build all platforms + run: | + make build-all BUILD_TARGETS="linux/amd64 linux/arm64 linux/riscv64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64" + + - name: Package artifacts + run: make package-all BUILD_TARGETS="linux/amd64 linux/arm64 linux/riscv64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64" + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: release-artifacts + path: | + build/*.tar.gz + build/*.zip + build/checksums.txt + if-no-files-found: error + + publish-release: + needs: build-and-package + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: release-artifacts + path: build + + - name: Resolve tag + id: tag + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.tag }}" ]; then + echo "name=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" + else + echo "name=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + fi + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.tag.outputs.name }} + name: ${{ steps.tag.outputs.name }} + generate_release_notes: true + files: | + build/*.tar.gz + build/*.zip + build/checksums.txt