-
-
Notifications
You must be signed in to change notification settings - Fork 189
190 lines (167 loc) · 6.12 KB
/
release-pipeline.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
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
name: Release Pipeline
# Execution needs to be triggered manually at https://github.com/BetterDiscord/Installer/actions/workflows/release-pipeline.yml.
# This pipeline is pretty hard-coded and will deliver
# identical results no matter the branch it's run against.
on:
workflow_dispatch:
inputs:
version_tag:
description: The version label to be used for this release
required: true
concurrency: release
jobs:
# Checkout 'release', merge 'development', bump version, upload source artifact.
prepare:
name: Prepare Repo
runs-on: ubuntu-latest
outputs:
old_version: ${{ steps.version_bump.outputs.old_version }}
new_version: ${{ steps.version_bump.outputs.new_version }}
steps:
- name: checkout 'release'
uses: actions/checkout@v2
with:
ref: 'release'
fetch-depth: 0
- name: merge 'development' and bump version
id: version_bump
run: |
git config --global user.name "BetterDiscord CI"
git config --global user.email "[email protected]"
git merge --no-ff --no-commit 'origin/development'
node << 'EOF'
const fs = require("fs");
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf-8"));
let version = process.env.VERSION_TAG;
if (/^v\d/.test(version)) version = version.slice(1);
if (
!/^\d/.test(version) || version.includes("-") && !/[a-z\d]$/.test(version)
) throw new Error(`Bad version tag: '${process.env.VERSION_TAG}'`);
if (version.includes("-") && !/\.\d+$/.test(version)) version += ".0";
version = version.replace(/\.+/g, ".");
fs.writeFileSync("package.json", JSON.stringify({
...packageJson,
version,
}, null, 2) + "\n");
let oldVersion = "v" + packageJson.version;
let newVersion = "v" + version;
console.log(`::set-output name=old_version::${oldVersion}`);
console.log(`::set-output name=new_version::${newVersion}`);
fs.writeFileSync("commit-message", `CI: Prepare release '${newVersion}`);
EOF
git add package.json
git commit -F commit-message
env:
VERSION_TAG: ${{ github.event.inputs.version_tag }}
- uses: actions/upload-artifact@v2
with:
name: source
path: |
./*
!.git/config
# Download source artifact, build, upload build artifact.
# Runs once on each release platform.
build:
name: Build
needs: prepare
strategy:
fail-fast: true
matrix:
os:
# ordered by how fast they build (muh cosmetics)
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/download-artifact@v2
with:
name: source
- run: yarn install && yarn dist
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
- uses: actions/upload-artifact@v2
if: ${{ success() && matrix.os == 'ubuntu-latest' }}
with:
name: build
path: dist/BetterDiscord-Linux.AppImage
if-no-files-found: error
- uses: actions/upload-artifact@v2
if: ${{ success() && matrix.os == 'windows-latest' }}
with:
name: build
path: dist/BetterDiscord-Windows.exe
if-no-files-found: error
- if: ${{ success() && matrix.os == 'macos-latest' }}
run: mv -f dist/BetterDiscord-*-mac.zip dist/BetterDiscord-Mac.zip
- if: ${{ success() && matrix.os == 'macos-latest' }}
uses: actions/upload-artifact@v2
with:
name: build
path: dist/BetterDiscord-Mac.zip
if-no-files-found: error
# Download source artifact, push to 'release'.
push_changes:
name: Push Version Bump
needs:
- prepare
- build
runs-on: ubuntu-latest
outputs:
sha_1: ${{ steps.push.outputs.sha_1 }}
steps:
- name: checkout 'development'
uses: actions/checkout@v2
with:
ref: 'development'
token: ${{ secrets.CI_PAT }}
clean: false
- uses: actions/download-artifact@v2
with:
name: source
- name: merge 'release' and push everything
id: push
run: |
git checkout 'development'
git config --global user.name "BetterDiscord CI"
git config --global user.email "[email protected]"
# TODO: rebase 'development' on 'release'
git merge --ff-only --no-commit 'release'
SHA1=$(git rev-parse --verify HEAD)
git tag "$NEW_VERSION" "$SHA1"
git push --all && git push --tags
echo "::set-output name=sha_1::$SHA1"
env:
NEW_VERSION: ${{ needs.prepare.outputs.new_version }}
# Download build artifact, do github release.
publish:
name: Draft Release
needs:
- prepare
- build
- push_changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ needs.push_changes.outputs.sha_1 }}
- name: authenticate gh-cli
run: echo "$GITHUB_TOKEN_STUPIDO" | gh auth login --with-token
env:
GITHUB_TOKEN_STUPIDO: ${{ secrets.CI_PAT }}
- uses: actions/download-artifact@v2
with:
name: build
- name: upload release draft
run: |
gh release create "$NEW_VERSION" --draft --title "$NEW_VERSION" --target "$SHA1" --generate-notes \
"BetterDiscord-Linux.AppImage#Linux (AppImage)" \
"BetterDiscord-Mac.zip#Mac OS (Zip)" \
"BetterDiscord-Windows.exe#Windows (Exe)"
env:
SHA1: ${{ needs.push_changes.outputs.sha_1 }}
OLD_VERSION: ${{ needs.prepare.outputs.old_version }}
NEW_VERSION: ${{ needs.prepare.outputs.new_version }}
NAKED_INPUT_VERSION_TAG: ${{ github.event.inputs.version_tag }}
RELEASE_NOTES_TEMPLATE_LOCATION: .github/RELEASE_TEMPLATE.md