-
-
Notifications
You must be signed in to change notification settings - Fork 33
150 lines (130 loc) · 4.85 KB
/
release.yml
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
name: 'Release CI'
# This workflow triggers when a PR is merged into `main`, but jobs have conditions to only run when:
# - A PR is closed, merged into `main`, from a branch that matches the pattern `release/v*.*.*`
on:
pull_request:
branches:
- main
types: [opened, closed, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
jobs:
parse-semver:
if: contains(github.event.pull_request.head.ref, 'release/v')
name: Parse semver version
runs-on: [self-hosted]
outputs:
version: ${{ steps.tag.outputs.version }}
tags: ${{ steps.docker-tags.outputs.tags }}
steps:
- name: Extract version from branch name
id: tag
run: echo "version=$(echo ${{ github.event.pull_request.head.ref }} | sed -e 's/release\/v//')" >> $GITHUB_OUTPUT
- name: Print the tag
run: echo "The output version is ${{ steps.tag.outputs.version }}"
- name: Configure docker tags
id: docker-tags
run: |
echo "tags=latest,nightly,${{ steps.tag.outputs.version }}" >> $GITHUB_OUTPUT
echo "Docker tags are latest, nightly, and ${{ steps.tag.outputs.version }}"
push-or-load:
if: contains(github.event.pull_request.head.ref, 'release/v')
name: Configure docker load/push
runs-on: [self-hosted]
outputs:
load: ${{ steps.configure.outputs.load }}
push: ${{ steps.configure.outputs.push }}
platforms: ${{ steps.configure.outputs.platforms }}
steps:
- name: Configure environment
id: configure
run: |
if [[ ${{ github.event.pull_request.merged }} == true ]]; then
echo "push=true" >> $GITHUB_OUTPUT
echo "load=false" >> $GITHUB_OUTPUT
echo "platforms=linux/arm64/v8,linux/amd64" >> $GITHUB_OUTPUT
else
echo "push=false" >> $GITHUB_OUTPUT
echo "load=true" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
fi
- name: Print the configuration
run: |
echo "Platforms: ${{ steps.configure.outputs.platforms }}"
echo "Load: ${{ steps.configure.outputs.load }}"
echo "Push: ${{ steps.configure.outputs.push }}"
build-stable-docker:
if: contains(github.event.pull_request.head.ref, 'release/v')
name: Build docker image
runs-on: [self-hosted]
needs: [parse-semver, push-or-load]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build and push docker image
uses: ./.github/actions/build-docker
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
tags: ${{ needs.parse-semver.outputs.tags }}
load: ${{ needs.push-or-load.outputs.load }}
push: ${{ needs.push-or-load.outputs.push }}
platforms: ${{ needs.push-or-load.outputs.platforms }}
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}
# build-web-app:
# name: Build web app
# runs-on: [self-hosted]
# if: false # TODO: Enable this once 0.1.0 is ready
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Build the app
# uses: ./.github/actions/build-web
# - name: Upload the build
# uses: ./.github/actions/upload-artifact
# with:
# upload-name: webapp
# upload-path: apps/web/dist
# build-server:
# strategy:
# fail-fast: true
# matrix:
# platform: [macos, windows]
# name: Build server app
# needs: build-web
# runs-on: ${{ matrix.platform }}
# if: false # TODO: Enable this once 0.1.0 is ready
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Build the server
# uses: ./.github/actions/build-server
# with:
# platform: ${{ matrix.platform }}
# - name: Upload the server binary
# uses: ./.github/actions/upload-artifact
# with:
# upload-name: stump_server-${{ matrix.platform }}
# upload-path: target/release/stump_server
# # TODO: Investigate if I can just merge this with the above
# build-linux-server:
# name: Build server app (self-hosted runner)
# needs: build-web
# runs-on: [self-hosted]
# if: false # TODO: Enable this once 0.1.0 is ready
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Build the server
# uses: ./.github/actions/build-server
# with:
# platform: 'linux'
# - name: Upload the server binary
# uses: ./.github/actions/upload-artifact
# with:
# upload-name: stump_server-linux
# upload-path: target/release/stump_server