-
Notifications
You must be signed in to change notification settings - Fork 20
94 lines (81 loc) · 2.49 KB
/
release.yaml
File metadata and controls
94 lines (81 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.*'
env:
go-modules: ./... ./cm/...
jobs:
build:
name: Build binaries
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run Go tests
env:
# Test with the same environment as the build.
CGO_ENABLED: 0
run: go test ${{ env.go-modules }}
- name: Build binary
env:
# Disable cgo so the pre-built binary is statically linked for maximum compatibility.
CGO_ENABLED: 0
run: |
mkdir -p build
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o wit-bindgen-go ./cmd/wit-bindgen-go
tar -czvf build/wit-bindgen-go-${{ matrix.goos }}-${{ matrix.goarch }}.tgz wit-bindgen-go
rm wit-bindgen-go
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: wit-bindgen-go_${{ matrix.goos }}_${{ matrix.goarch }}
path: build/wit-bindgen-go-${{ matrix.goos }}-${{ matrix.goarch }}.tgz
retention-days: 1
release:
name: Create GitHub release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: build/
merge-multiple: true # all artifacts are downloaded to this directory
- name: Extract release notes
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
cd $GITHUB_WORKSPACE
./scripts/extract-changelog.sh $TAG_NAME > RELEASE_NOTES.md
cat RELEASE_NOTES.md
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ls -R build/
TAG_NAME=${GITHUB_REF#refs/tags/}
if [[ "$TAG_NAME" =~ .+-pre.* ]]; then
PRERELEASE_ARGS="--prerelease --latest=false"
else
PRERELEASE_ARGS=""
fi
gh release create "${{ github.ref_name }}" \
--notes-file RELEASE_NOTES.md \
--title "${{ github.ref_name }}" \
$PRERELEASE_ARGS \
build/*