-
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (82 loc) · 3.47 KB
/
Copy pathrelease.yml
File metadata and controls
95 lines (82 loc) · 3.47 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
95
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- name: Test
run: |
go vet ./...
go test ./...
- name: Build all platforms
run: |
mkdir -p build
VERSION="${GITHUB_REF_NAME#v}"
# Stamp the build SHA into the Exposure Receipt so a receipt names the
# exact binary that produced it (agent_build_sha).
LDFLAGS="-s -w -X main.Version=${VERSION} -X github.com/Quality-Max/qmax-receipt.BuildSHA=${GITHUB_SHA}"
GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o build/qmax-code-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o build/qmax-code-darwin-arm64 .
GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o build/qmax-code-linux-amd64 .
GOOS=linux GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o build/qmax-code-linux-arm64 .
GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o build/qmax-code-windows-amd64.exe .
GOOS=windows GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o build/qmax-code-windows-arm64.exe .
- name: Create archives
run: |
cd build
tar czf qmax-code-darwin-amd64.tar.gz qmax-code-darwin-amd64
tar czf qmax-code-darwin-arm64.tar.gz qmax-code-darwin-arm64
tar czf qmax-code-linux-amd64.tar.gz qmax-code-linux-amd64
tar czf qmax-code-linux-arm64.tar.gz qmax-code-linux-arm64
zip -q qmax-code-windows-amd64.zip qmax-code-windows-amd64.exe
zip -q qmax-code-windows-arm64.zip qmax-code-windows-arm64.exe
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
build/qmax-code-darwin-amd64.tar.gz
build/qmax-code-darwin-arm64.tar.gz
build/qmax-code-linux-amd64.tar.gz
build/qmax-code-linux-arm64.tar.gz
build/qmax-code-windows-amd64.zip
build/qmax-code-windows-arm64.zip
- name: Publish to public releases repo
env:
RELEASES_TOKEN: ${{ secrets.RELEASES_REPO_TOKEN }}
GH_TOKEN: ${{ secrets.RELEASES_REPO_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
if [ -z "$RELEASES_TOKEN" ]; then
echo "RELEASES_REPO_TOKEN not set — skipping public repo publish"
exit 0
fi
# Clone public releases repo
git clone "https://x-access-token:${RELEASES_TOKEN}@github.com/Quality-Max/qmax-code-releases.git" /tmp/releases
cd /tmp/releases
# Copy archives
cp $GITHUB_WORKSPACE/build/*.tar.gz .
cp $GITHUB_WORKSPACE/build/*.zip .
# Commit and push
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add *.tar.gz *.zip
git commit -m "release: ${TAG}" || true
git push
# Create release on public repo
gh release create "${TAG}" \
*.tar.gz *.zip \
--repo Quality-Max/qmax-code-releases \
--title "${TAG}" \
--notes "See full release notes: https://github.com/Quality-Max/qmax-code/releases/tag/${TAG}"