Skip to content

Commit

Permalink
Publish release binaries from GitHub actions (#52)
Browse files Browse the repository at this point in the history
Publish release assets from a GitHub action for major operating systems and architectures
  • Loading branch information
ignatk authored Jul 28, 2022
1 parent 657b7cb commit dc01847
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest , windows-latest ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
go: [ '1.13', '1.17', '>=1.18' ]
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} - go${{ matrix.go }}
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish release binaries

on:
release:
types:
- published

jobs:
publish:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} - go${{ matrix.go }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '>=1.18'
check-latest: true
- name: Run go build for amd64
run: |
go build -o gokey-amd64 ./cmd/gokey
env:
CGO_ENABLED: 0
- name: Run go build for arm64
run: |
go build -o gokey-arm64 ./cmd/gokey
env:
CGO_ENABLED: 0
GOARCH: arm64
- name: Upload Linux binary
if: runner.os == 'Linux'
run: |
ls
mv gokey-amd64 gokey-${{ github.ref_name }}-linux-amd64
mv gokey-arm64 gokey-${{ github.ref_name }}-linux-arm64
gh release upload ${{ github.ref_name }} gokey-${{ github.ref_name }}-linux-amd64 gokey-${{ github.ref_name }}-linux-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Windows binary
if: runner.os == 'Windows'
run: |
mv gokey-amd64 gokey-${{ github.ref_name }}-windows-amd64.exe
mv gokey-arm64 gokey-${{ github.ref_name }}-windows-arm64.exe
gh release upload ${{ github.ref_name }} gokey-${{ github.ref_name }}-windows-amd64.exe gokey-${{ github.ref_name }}-windows-arm64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload MacOS binary
if: runner.os == 'macOS'
run: |
mv gokey-amd64 gokey-${{ github.ref_name }}-darwin-amd64
mv gokey-arm64 gokey-${{ github.ref_name }}-darwin-arm64
gh release upload ${{ github.ref_name }} gokey-${{ github.ref_name }}-darwin-amd64 gokey-${{ github.ref_name }}-darwin-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit dc01847

Please sign in to comment.