feat: add windows support #38
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
on: | |
push: | |
branches: | |
- main | |
name: release-please | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
release-please: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Step 2: Set up Go environment | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
# Step 3: Use release-please to create a release | |
- name: Create release | |
id: release # Added ID for referencing outputs | |
uses: googleapis/release-please-action@v4 | |
with: | |
release-type: go | |
# Step 4: Update the version in the build and perform multi-platform builds | |
- name: Build for multiple platforms | |
if: ${{ steps.release.outputs.release_created }} | |
run: | | |
VERSION="${{ steps.release.outputs.version }}" | |
echo "Updating version to ${VERSION}" | |
mkdir -p bin | |
# Build for Linux | |
GOOS=linux GOARCH=amd64 go build -o bin/hkup-linux -ldflags="-s -w -X cmd.version=${VERSION}" . | |
# Build for Darwin/macOS | |
GOOS=darwin GOARCH=amd64 go build -o bin/hkup-darwin -ldflags="-s -w -X cmd.version=${VERSION}" . | |
# Build for Windows | |
GOOS=windows GOARCH=amd64 go build -o bin/hkup.exe -ldflags="-s -w -X cmd.version=${VERSION}" . | |
# Step 5: Upload Release Artifacts if a release was created | |
- name: Upload Release Artifacts | |
if: ${{ steps.release.outputs.release_created }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ steps.release.outputs.tag_name }} \ | |
bin/* |