Skip to content

Commit

Permalink
Enhance GitHub Actions workflow for multi-platform builds and releases
Browse files Browse the repository at this point in the history
  • Loading branch information
trinhminhtriet committed Nov 6, 2024
1 parent 8643ba1 commit 10088ef
Showing 1 changed file with 53 additions and 6 deletions.
59 changes: 53 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Build and Release

on:
push:
Expand All @@ -8,16 +8,63 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.23"

- name: Build
run: go build -v ./...
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -o blast-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: blast-${{ matrix.goos }}-${{ matrix.goarch }}
path: blast-${{ matrix.goos }}-${{ matrix.goarch }}

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test
run: go test -v ./...
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: blast-${{ matrix.goos }}-${{ matrix.goarch }}
path: ./artifacts

- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false

- name: Upload release assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/blast-*
asset_name: blast-${{ matrix.goos }}-${{ matrix.goarch }}
asset_content_type: application/octet-stream

0 comments on commit 10088ef

Please sign in to comment.