-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (151 loc) · 5.39 KB
/
build-stable.yaml
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Release Build
on:
push:
tags:
- 'v*'
env:
APP_NAME: 'nauthilus'
MAINTAINER: 'croessner'
DESC: 'Multi purpose authentication server'
CHGELOG_VERSION: '0.15.4'
jobs:
build-artifact:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.23.x
- run: |
cd server && \
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -mod=vendor -ldflags="-s -X main.version=${GITHUB_REF#refs/tags/}-${GITHUB_SHA:0:8}" -o ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} .
- name: Create artifact
run: |
os="${{ runner.os }}"
assets="${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}"
echo "$assets"
mkdir -p "dist/$assets"
cp server/${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} LICENSE README.md NOTICE.md "dist/$assets/"
cp systemd/${{ env.APP_NAME }}.service "dist/$assets/"
(
cd dist
tar czf "$assets.tar.gz" "$assets"
ls -lah *.*
)
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
dist/*.tar.gz
build-linux-packages:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ linux ]
goarch: [ amd64, arm64 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.23.x
- run: |
cd server && \
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -mod=vendor -ldflags="-s -X main.version=${GITHUB_REF#refs/tags/}-${GITHUB_SHA:0:8}" -o ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Copy binaries
run: |
mkdir -p .debpkg/usr/sbin
mkdir -p .debpkg/usr/lib/systemd/system
mkdir -p .debpkg/usr/share/doc/${{ env.APP_NAME }}
cp server/${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} .debpkg/usr/sbin/${{ env.APP_NAME }}
cp systemd/${{ env.APP_NAME }}.service .debpkg/usr/lib/systemd/system/
cp LICENSE README.md NOTICE.md .debpkg/usr/share/doc/${{ env.APP_NAME }}/
- uses: jiro4989/build-deb-action@v3
with:
package: ${{ env.APP_NAME }}
package_root: .debpkg
maintainer: ${{ env.MAINTAINER }}
version: ${{ github.ref }}
arch: '${{ matrix.goarch }}'
desc: '${{ env.DESC }}'
- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.goos }}-${{ matrix.goarch }}-deb
path: |
./*.deb
create-release:
runs-on: ubuntu-latest
needs:
- build-artifact
- build-linux-packages
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
run: |
wget https://github.com/git-chglog/git-chglog/releases/download/v${{ env.CHGELOG_VERSION }}/git-chglog_${{ env.CHGELOG_VERSION }}_linux_amd64.tar.gz
tar xzf git-chglog_${{ env.CHGELOG_VERSION }}_linux_amd64.tar.gz
chmod +x git-chglog
./git-chglog --output ./changelog $(git describe --tags $(git rev-list --tags --max-count=1))
- name: Install GitHub CLI
run: sudo apt update && sudo apt install -y gh
- name: Create Release
env:
GH_TOKEN: ${{ secrets.NAUTHILUS_RELEASE }}
run: gh release create ${{ github.ref_name }} ./changelog --title "Release ${{ github.ref_name }}" --notes-file ./changelog --draft=false --prerelease=false
upload-release:
runs-on: ubuntu-latest
needs: create-release
strategy:
matrix:
goos: [ linux ]
goarch: [ amd64, arm64 ]
include:
- os: ubuntu-latest
asset_suffix: .tar.gz
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitHub CLI
run: sudo apt update && sudo apt install -y gh
- name: Download Artifact
env:
GH_TOKEN: ${{ secrets.NAUTHILUS_RELEASE }}
run: gh run download --name artifact-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Upload Asset
env:
GH_TOKEN: ${{ secrets.NAUTHILUS_RELEASE }}
run: gh release upload ${{ github.ref_name }} ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.asset_suffix }}
upload-linux-packages:
runs-on: ubuntu-latest
needs: create-release
strategy:
matrix:
goos: [ linux ]
goarch: [ amd64, arm64 ]
include:
- pkg: deb
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitHub CLI
run: sudo apt update && sudo apt install -y gh
- name: Download Artifact
env:
GH_TOKEN: ${{ secrets.NAUTHILUS_RELEASE }}
run: gh run download --name artifact-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.pkg }}
- run: echo "ASSET_NAME=$(ls *.${{ matrix.pkg }} | head -n 1)" >> "$GITHUB_ENV"
- name: Upload Asset
env:
GITHUB_TOKEN: ${{ secrets.NAUTHILUS_RELEASE }}
run: gh release upload ${{ github.ref_name }} $ASSET_NAME