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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
name: CI
on:
push:
branches: [ master ]
tags: "[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches: [ master ]
workflow_dispatch:
env:
DOTNET_VERSION: '8'
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set Environment Variables
run: |
echo "VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)+$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Web
run: ./bin/build --web-only
- name: Dotnet
run: ./bin/build --dotnet-only --version ${{ env.VERSION }}
- name: Upload Static Web Content
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: web-${{ env.VERSION }}
path: src/web/build
publish:
name: Publish
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
runtime:
- "win-x64"
- "win-arm64"
- "linux-x64"
- "linux-arm"
- "linux-arm64"
- "linux-musl-x64"
- "linux-musl-arm"
- "linux-musl-arm64"
- "osx-x64"
- "osx-arm64"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set Environment Variables
run: |
echo "VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)+$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Download Static Web Content
uses: actions/download-artifact@v4
with:
name: web-${{ env.VERSION }}
path: src/slskd/wwwroot
- name: Build ${{ matrix.runtime }}
run: bin/publish --no-prebuild --runtime ${{ matrix.runtime }} --version ${{ env.VERSION }}
- name: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: slskd-${{ env.VERSION }}-${{ matrix.runtime }}
path: dist/${{ matrix.runtime }}
docker:
name: Build Docker Image
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# docker tags aren't compatible with semver, therefore + can't be used to delimit the version and SHA
# https://github.com/opencontainers/distribution-spec/issues/154
# CONTAINER_VERSION is used in Docker tags and must use a hyphen (-) delimiter between the tag and SHA
# APP_VERSION is passed as a Docker build arg and used to publish the app and must use a plus (+) delimiter between the tag and SHA
- name: Set Environment Variables
run: |
echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "CONTAINER_VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "APP_VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)+$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "BUILD_DATE=$(date --iso-8601=s)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PAT }}
- name: Build and push Canary
if: "!startsWith(github.ref, 'refs/tags/')"
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
build-args: |
TAG=${{ env.TAG }}
VERSION=${{ env.APP_VERSION }}
REVISION=${{ env.REVISION }}
BUILD_DATE=${{ env.BUILD_DATE }}
tags: |
slskd/slskd:${{ env.CONTAINER_VERSION }}
slskd/slskd:canary
ghcr.io/slskd/slskd:${{ env.CONTAINER_VERSION }}
ghcr.io/slskd/slskd:canary
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push Release
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
build-args: |
VERSION=${{ env.APP_VERSION }}
tags: |
slskd/slskd:${{ env.CONTAINER_VERSION }}
slskd/slskd:${{ env.TAG }}
slskd/slskd:canary
slskd/slskd:latest
ghcr.io/slskd/slskd:${{ env.CONTAINER_VERSION }}
ghcr.io/slskd/slskd:${{ env.TAG }}
ghcr.io/slskd/slskd:canary
ghcr.io/slskd/slskd:latest
cache-from: type=gha
cache-to: type=gha,mode=max
release:
name: Create Release
runs-on: ubuntu-latest
needs: [publish, docker]
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
runtime:
- "win-x64"
- "win-arm64"
- "linux-x64"
- "linux-arm"
- "linux-arm64"
- "linux-musl-x64"
- "linux-musl-arm"
- "linux-musl-arm64"
- "osx-x64"
- "osx-arm64"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set Environment Variables
run: |
echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)+$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Download ${{ matrix.runtime }} Binaries
uses: actions/download-artifact@v4
with:
name: slskd-${{ env.VERSION }}-${{ matrix.runtime }}
path: dist/${{ matrix.runtime }}
- name: Zip ${{ matrix.runtime }} Binaries
run: |
cd dist/${{ matrix.runtime }}
if [ -f "slskd" ]; then
chmod +x slskd
fi
zip -r ../../slskd-${{ env.TAG }}-${{ matrix.runtime }}.zip .
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
slskd-${{ env.TAG }}-${{ matrix.runtime }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|