Skip to content

Commit 14fb2eb

Browse files
authored
Add release workflow for generator asset (#33)
* Add release workflow for generator asset This workflow builds the go generator for multiple releases on version tags, and then adds the assets to the release on Github. This should ease the recuperation of the generator. Closes: #30
1 parent 7f5916c commit 14fb2eb

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build and Release Binaries
2+
3+
on: [push]
4+
permissions:
5+
contents: write
6+
7+
jobs:
8+
build:
9+
name: 'Build Assets'
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
build: [linux_amd64, windows_amd64, darwin_amd64, darwin_arm64]
14+
include:
15+
- build: linux_amd64
16+
goos: linux
17+
goarch: amd64
18+
ext: ''
19+
- build: windows_amd64
20+
goos: windows
21+
goarch: amd64
22+
ext: '.exe'
23+
- build: darwin_amd64
24+
goos: darwin
25+
goarch: amd64
26+
ext: ''
27+
- build: darwin_arm64
28+
goos: darwin
29+
goarch: arm64
30+
ext: ''
31+
steps:
32+
- uses: actions/checkout@v3
33+
- name: Set up Go
34+
uses: actions/setup-go@v4
35+
with:
36+
go-version: "1.20"
37+
check-latest: true
38+
- name: Build
39+
run: |
40+
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build cmd/autometrics/main.go
41+
mv main${{ matrix.ext }} autometrics${{ matrix.ext }}
42+
43+
- name: Pack (Zip)
44+
run: |
45+
zip autometrics-${{ matrix.build }}.zip -v -z autometrics${{ matrix.ext }}
46+
- name: Upload (Zip)
47+
uses: actions/upload-artifact@v3
48+
with:
49+
name: autometrics ${{ matrix.build }}
50+
path: autometrics-${{ matrix.build }}.zip
51+
if-no-files-found: error
52+
retention-days: 7
53+
54+
add_assets:
55+
name: 'Add Assets'
56+
if: startsWith(github.ref, 'refs/tags/')
57+
runs-on: ubuntu-latest
58+
needs: [build]
59+
steps:
60+
- name: Fetch Linux (AMD64) build
61+
uses: actions/download-artifact@v3
62+
with:
63+
name: autometrics linux_amd64
64+
- name: Fetch Windows (AMD64) build
65+
uses: actions/download-artifact@v3
66+
with:
67+
name: autometrics windows_amd64
68+
- name: Fetch Darwin (AMD64) build
69+
uses: actions/download-artifact@v3
70+
with:
71+
name: autometrics darwin_amd64
72+
- name: Fetch Darwin (ARM64) build
73+
uses: actions/download-artifact@v3
74+
with:
75+
name: autometrics darwin_arm64
76+
- name: Release with Notes
77+
uses: softprops/action-gh-release@v1
78+
with:
79+
files: |
80+
*.zip
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)