-
-
Notifications
You must be signed in to change notification settings - Fork 1
169 lines (148 loc) · 5.65 KB
/
release-please.yml
File metadata and controls
169 lines (148 loc) · 5.65 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Release Please
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
packages: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
id: release
with:
release-type: go
package-name: systemofadownload
build-and-upload:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: true
- name: Build binaries
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
VERSION=${{ needs.release-please.outputs.tag_name }}
# Build server
go build -o dist/server-${GOOS}-${GOARCH}${{ matrix.goos == 'windows' && '.exe' || '' }} \
-ldflags "-s -w -X main.Version=${VERSION}" \
./cmd/server
# Build worker
go build -o dist/worker-${GOOS}-${GOARCH}${{ matrix.goos == 'windows' && '.exe' || '' }} \
-ldflags "-s -w -X main.Version=${VERSION}" \
./cmd/worker
# Build frontend
go build -o dist/frontend-${GOOS}-${GOARCH}${{ matrix.goos == 'windows' && '.exe' || '' }} \
-ldflags "-s -w -X main.Version=${VERSION}" \
./cmd/frontend
# Create archives
if [ "${{ matrix.goos }}" = "windows" ]; then
cd dist
zip ../systemofadownload-${VERSION}-${GOOS}-${GOARCH}.zip \
server-${GOOS}-${GOARCH}.exe \
worker-${GOOS}-${GOARCH}.exe \
frontend-${GOOS}-${GOARCH}.exe
cd ..
else
tar -czf systemofadownload-${VERSION}-${GOOS}-${GOARCH}.tar.gz \
-C dist \
server-${GOOS}-${GOARCH} \
worker-${GOOS}-${GOARCH} \
frontend-${GOOS}-${GOARCH}
fi
- name: Upload release artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ needs.release-please.outputs.tag_name }}
GOOS=${{ matrix.goos }}
GOARCH=${{ matrix.goarch }}
if [ "$GOOS" = "windows" ]; then
ARCHIVE="systemofadownload-${VERSION}-${GOOS}-${GOARCH}.zip"
else
ARCHIVE="systemofadownload-${VERSION}-${GOOS}-${GOARCH}.tar.gz"
fi
gh release upload ${VERSION} ${ARCHIVE} --clobber
docker-release:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: App image metadata
id: app-meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}},value=${{ needs.release-please.outputs.tag_name }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release-please.outputs.tag_name }}
type=raw,value=latest
- name: Migrate image metadata
id: migrate-meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: ghcr.io/${{ github.repository }}/migrate
tags: |
type=semver,pattern={{version}},value=${{ needs.release-please.outputs.tag_name }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release-please.outputs.tag_name }}
type=raw,value=latest
- name: Build and push app image
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .
target: app
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.app-meta.outputs.tags }}
labels: ${{ steps.app-meta.outputs.labels }}
cache-from: type=gha,scope=app
cache-to: type=gha,scope=app,mode=max
build-args: |
VERSION=${{ needs.release-please.outputs.tag_name }}
- name: Build and push migrate image
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .
target: migrate
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.migrate-meta.outputs.tags }}
labels: ${{ steps.migrate-meta.outputs.labels }}
cache-from: type=gha,scope=migrate
cache-to: type=gha,scope=migrate,mode=max