Update release.yml #15
Workflow file for this 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
name: Build and Release | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
push: | |
branches: | |
- main | |
paths: | |
- "**/*.go" | |
- "go.mod" | |
- "go.sum" | |
- ".github/workflows/*.yml" | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
- "**/*.go" | |
- "go.mod" | |
- "go.sum" | |
- ".github/workflows/*.yml" | |
jobs: | |
build: | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
# Include amd64 on all platforms. | |
goos: [linux] | |
goarch: [amd64, arm64] | |
include: | |
# BEGIN Linux ARM64 | |
- goos: linux | |
goarch: arm64 | |
# END Linux ARM64 | |
# BEGIN Linux AMD64 | |
- goos: linux | |
goarch: amd64 | |
# END Linux AMD64 | |
fail-fast: false | |
runs-on: ubuntu-latest | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
GOARM: ${{ matrix.goarm }} | |
CGO_ENABLED: 0 | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v4 | |
- name: Show workflow information | |
run: | | |
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) | |
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" | |
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
check-latest: true | |
- name: Get project dependencies | |
run: go mod download | |
- name: Build db_backup_go | |
run: | | |
go build | |
- name: Get Version Number | |
run: | | |
versionNum=$(cat main.go | grep "version :=" | awk -F "\"" '{print $2}') | |
echo "VERSION=$versionNum" >> $GITHUB_ENV | |
- name: Change the name | |
run: | | |
mv db_backup_go db_backup_go_${{ env.ASSET_NAME }} | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./db_backup_go_${{ env.ASSET_NAME }}* | |
tag: ${{ env.VERSION }} | |
release_name: "db_backup_go" | |
file_glob: true |