Build go binary #2
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 go binary | |
# Configures this workflow to run every time a change is pushed to the branch called `release`. | |
on: | |
push: | |
branches: [ 'master' ] | |
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. | |
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
# | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. | |
- name: Setup Go 1.23.x | |
uses: actions/setup-go@v5 | |
with: | |
# Semantic version range syntax or exact version of Go | |
go-version: '1.23.4' | |
- name: Install dependencies | |
run: | | |
go mod download | |
- name: Build | |
run: | | |
go build -v ./... | |
- name: Test | |
run: | | |
go test -v ./... | |
- name: Cross-compile | |
run: | | |
GOOS=linux GOARCH=amd64 go build -o telebackup_linux_amd64 cmd/telebackup/main.go | |
GOOS=linux GOARCH=arm64 go build -o telebackup_linux_arm64 cmd/telebackup/main.go | |
GOOS=windows GOARCH=amd64 go build -o telebackup_windows_amd64.exe cmd/telebackup/main.go | |
GOOS=darwin GOARCH=amd64 go build -o telebackup_darwin_amd64 cmd/telebackup/main.go | |
GOOS=darwin GOARCH=arm64 go build -o telebackup_darwin_arm64 cmd/telebackup/main.go | |
- name: Publish artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: telebackup-binaries | |
path: | | |
telebackup_linux_amd64 | |
telebackup_linux_arm64 | |
telebackup_windows_amd64.exe | |
telebackup_darwin_amd64 | |
telebackup_darwin_arm64 | |