feat: simplified build process #12
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 | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
cache: true | |
- name: Run Tests | |
run: go test -v ./... | |
- name: Build Binaries | |
run: | | |
# Create dist directory | |
mkdir -p dist | |
# Build for Linux | |
GOOS=linux GOARCH=amd64 go build -o dist/apkx-linux-amd64 ./cmd/apkx/main.go | |
tar czf dist/apkx-linux-amd64.tar.gz -C dist apkx-linux-amd64 LICENSE README.md config/ | |
# Build for Windows | |
GOOS=windows GOARCH=amd64 go build -o dist/apkx-windows-amd64.exe ./cmd/apkx/main.go | |
zip -j dist/apkx-windows-amd64.zip dist/apkx-windows-amd64.exe LICENSE README.md | |
cp -r config dist/config-windows | |
zip -r dist/apkx-windows-amd64.zip dist/config-windows | |
# Build for macOS | |
GOOS=darwin GOARCH=amd64 go build -o dist/apkx-darwin-amd64 ./cmd/apkx/main.go | |
tar czf dist/apkx-darwin-amd64.tar.gz -C dist apkx-darwin-amd64 LICENSE README.md config/ | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
dist/*.tar.gz | |
dist/*.zip | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |