-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (135 loc) · 4.27 KB
/
release.yml
File metadata and controls
153 lines (135 loc) · 4.27 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Release
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
suffix: linux-amd64
- goos: linux
goarch: arm64
suffix: linux-arm64
- goos: linux
goarch: arm
goarm: "7"
suffix: linux-armv7
- goos: darwin
goarch: amd64
suffix: darwin-amd64
- goos: darwin
goarch: arm64
suffix: darwin-arm64
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Set version info
id: info
run: |
COMMIT="$(git rev-parse --short HEAD)"
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
VERSION="${GITHUB_REF_NAME}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "commit=${COMMIT}" >> "$GITHUB_OUTPUT"
echo "date=${DATE}" >> "$GITHUB_OUTPUT"
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: "0"
run: |
go build \
-trimpath \
-ldflags="-s -w \
-X main.version=${{ steps.info.outputs.version }} \
-X main.commit=${{ steps.info.outputs.commit }} \
-X main.buildDate=${{ steps.info.outputs.date }}" \
-o "dist/sysfig-${{ matrix.suffix }}" \
./cmd/sysfig
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: sysfig-${{ matrix.suffix }}
path: dist/sysfig-${{ matrix.suffix }}
publish:
name: Publish release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout (full history for git-cliff)
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v6.0.0
with:
path: dist
merge-multiple: true
- name: Install nfpm
run: |
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' \
| sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt-get update -qq
sudo apt-get install -y nfpm
- name: Build packages (.deb / .rpm / .apk)
run: |
VERSION=${GITHUB_REF_NAME#v}
for arch in amd64 arm64; do
cp dist/sysfig-linux-${arch} dist/sysfig-pkg
for fmt in deb rpm apk; do
GOARCH=${arch} VERSION=${VERSION} \
nfpm package \
--config contrib/pkg/nfpm.yaml \
--packager ${fmt} \
--target dist/
done
done
rm -f dist/sysfig-pkg
- name: Generate checksums
run: |
cd dist
sha256sum sysfig-* sysfig_* > checksums.txt
cat checksums.txt
- name: Install git-cliff
run: |
VERSION="2.12.0"
curl -LsSf \
"https://github.com/orhun/git-cliff/releases/download/v${VERSION}/git-cliff-${VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
-o /tmp/git-cliff.tar.gz
tar -xzf /tmp/git-cliff.tar.gz -C /tmp
sudo install -m 0755 "/tmp/git-cliff-${VERSION}/git-cliff" /usr/local/bin/git-cliff
- name: Generate changelog
id: changelog
run: |
PREV=$(git tag --sort=-version:refname | sed -n '2p')
if [ -n "$PREV" ]; then
git cliff "${PREV}..HEAD" --config cliff.toml -o /tmp/CHANGELOG_RELEASE.md
else
git cliff --config cliff.toml -o /tmp/CHANGELOG_RELEASE.md
fi
echo "body<<EOF" >> "$GITHUB_OUTPUT"
cat /tmp/CHANGELOG_RELEASE.md >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Publish tagged release
uses: softprops/action-gh-release@v2.6.1
with:
body: ${{ steps.changelog.outputs.body }}
files: |
dist/sysfig-*
dist/sysfig_*
dist/checksums.txt