-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add GitHub release workflow for automated binary distribution
- Loading branch information
1 parent
55a8f2a
commit 50ca373
Showing
2 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Docker Build and Push | ||
name: Docker Release | ||
|
||
on: | ||
workflow_run: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Github Release | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- Lint Test Build | ||
branches: | ||
- master | ||
types: | ||
- completed | ||
|
||
jobs: | ||
release: | ||
name: Release to GitHub | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Install dependencies | ||
run: go mod download | ||
|
||
- name: Build binary | ||
run: | | ||
mkdir -p dist | ||
GOOS=linux GOARCH=amd64 go build -o dist/GoCrab-linux-amd64 . | ||
GOOS=darwin GOARCH=amd64 go build -o dist/GoCrab-darwin-amd64 . | ||
GOOS=windows GOARCH=amd64 go build -o dist/GoCrab-windows-amd64.exe . | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ github.ref_name }} | ||
release_name: "GoCrab ${{ github.ref_name }}" | ||
body: | | ||
Automated release for GoCrab version ${{ github.ref_name }}. | ||
Includes pre-built binaries for Linux, macOS, and Windows. | ||
draft: false | ||
prerelease: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload Release Assets | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: dist/GoCrab-linux-amd64 | ||
asset_name: GoCrab-linux-amd64 | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload macOS Binary | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: dist/GoCrab-darwin-amd64 | ||
asset_name: GoCrab-darwin-amd64 | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload Windows Binary | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: dist/GoCrab-windows-amd64.exe | ||
asset_name: GoCrab-windows-amd64.exe | ||
asset_content_type: application/octet-stream |