From d124ec1466c8fabc46f8ed1bdc41b1403c3e78ed Mon Sep 17 00:00:00 2001 From: Raffaele Di Fazio Date: Sun, 5 Jan 2025 11:09:57 +0100 Subject: [PATCH] Add GitHub action to create Go binaries for releases --- .github/workflows/release.yml | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3178e35 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22.2 + + - name: Build binaries + run: | + mkdir -p dist + GOOS=linux GOARCH=amd64 go build -o dist/gcp-linux-amd64 ./cmd/gcp + GOOS=linux GOARCH=arm64 go build -o dist/gcp-linux-arm64 ./cmd/gcp + GOOS=darwin GOARCH=amd64 go build -o dist/gcp-darwin-amd64 ./cmd/gcp + GOOS=darwin GOARCH=arm64 go build -o dist/gcp-darwin-arm64 ./cmd/gcp + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload release assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/gcp-linux-amd64 + asset_name: gcp-linux-amd64 + asset_content_type: application/octet-stream + + - name: Upload release assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/gcp-linux-arm64 + asset_name: gcp-linux-arm64 + asset_content_type: application/octet-stream + + - name: Upload release assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/gcp-darwin-amd64 + asset_name: gcp-darwin-amd64 + asset_content_type: application/octet-stream + + - name: Upload release assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/gcp-darwin-arm64 + asset_name: gcp-darwin-arm64 + asset_content_type: application/octet-stream