-
Notifications
You must be signed in to change notification settings - Fork 9
228 lines (209 loc) · 7.81 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
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
221
222
223
224
225
226
227
228
# This workflow triggers on a new release that is being created
# It build-pushes a release image to DockerHub
# and it attaches Linux, MacOS and Windows binary files to the release
name: Release
on:
release:
types: [created]
jobs:
add-release-notes:
name: Add release notes to artefacts
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Upload macOS artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_name: ReleaseNotes.md
asset_path: ReleaseNotes.md
asset_content_type: text/markdown
docker-hub:
name: Build push image to DockerHub
runs-on: ubuntu-22.04
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
ampersandtarski/ampersand
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push to Docker Hub
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }} # see meta step above
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_SHA=${{github.sha}}
GIT_Branch=${{github.ref}}
add-release-artefacts:
name: Add artefacts to release
needs:
[
build-without-test-ubuntu,
build-without-test-macOS,
build-without-test-windows,
]
runs-on: ubuntu-22.04
steps:
- name: Download artifacts (Linux)
uses: actions/download-artifact@v4
with:
name: Linux-binaries
path: release/Linux
- name: get-version
run: |
chmod +x release/Linux/ampersand
echo "version=$(release/Linux/ampersand --numeric-version)" >> $GITHUB_OUTPUT
echo "theReleaseName=$(echo "v$(release/Linux/ampersand --numeric-version) ($(date '+%_d %B %Y'))")" >> $GITHUB_OUTPUT
id: get-version
- name: zip the binaries (Linux)
uses: papeloto/action-zip@v1
with:
files: release/Linux/
dest: release/linux-binaries-v${{ steps.get-version.outputs.version }}.zip
- name: Download artifacts (macOS)
uses: actions/download-artifact@v4
with:
name: macOS-binaries
path: release/macOS
- name: zip the binaries (macOS)
uses: papeloto/action-zip@v1
with:
files: release/macOS/
dest: release/macOS-binaries-v${{ steps.get-version.outputs.version }}.zip
- name: Download artifacts (Windows)
uses: actions/download-artifact@v4
with:
name: Windows-binaries
path: release/Windows
- name: zip the binaries (Windows)
uses: papeloto/action-zip@v1
with:
files: release/Windows/
dest: release/Windows-binaries-v${{ steps.get-version.outputs.version }}.zip
- name: Upload Linux artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_name: ampersand-${{ steps.get-version.outputs.version }}-Linux-binaries.zip
asset_path: release/linux-binaries-v${{ steps.get-version.outputs.version }}.zip
asset_content_type: application/zip
- name: Upload macOS artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_name: ampersand-${{ steps.get-version.outputs.version }}-macOS-binaries.zip
asset_path: release/macOS-binaries-v${{ steps.get-version.outputs.version }}.zip
asset_content_type: application/zip
- name: Upload Windows artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_name: ampersand-${{ steps.get-version.outputs.version }}-Windows-binaries.zip
asset_path: release/Windows-binaries-v${{ steps.get-version.outputs.version }}.zip
asset_content_type: application/zip
build-without-test-ubuntu:
name: Build without test on ubuntu-22.04 🏗 🧪
runs-on: ubuntu-22.04
steps:
- name: Checkout project contents 📡
uses: actions/checkout@v4
- name: Set up Mariadb 🧰
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "mariadb-11.5"
- name: build without test 🏗 🧪
uses: freckle/stack-action@v5 # stack-action does all these steps: dependencies, build, test.
with:
stack-build-arguments: "--copy-bins --flag ampersand:buildAll"
upgrade-stack: false
test: false
- name: Upload artifacts (Linux)
uses: actions/upload-artifact@v4
with:
name: Linux-binaries
path: /home/runner/.local/bin/*
build-without-test-macOS:
name: Build without test on macos-13 🏗 🧪
runs-on: macos-13
steps:
- name: Checkout project contents 📡
uses: actions/checkout@v4
- name: Set up Mariadb 🧰
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "mariadb-11.5"
# See issue https://github.com/freckle/stack-action/issues/80 for why we need to install stack and php as well
## - run: curl -sSL https://get.haskellstack.org/ | sh
- run: brew install php
- name: Build without test 🏗 🧪
uses: freckle/stack-action@v5
with:
stack-build-arguments: "--copy-bins --flag ampersand:buildAll"
upgrade-stack: false
test: false
- name: Upload artifacts (macOS)
uses: actions/upload-artifact@v4
with:
name: macOS-binaries
path: /Users/runner/.local/bin/*
build-without-test-windows:
name: build without test on windows-2022 🏗 🧪
runs-on: windows-2022
steps:
- name: Checkout project contents 📡
uses: actions/checkout@v4
# - name: Use cache (manually) 📦 # See https://github.com/freckle/stack-cache-action/issues/5
# uses: actions/cache@v4
# # TODO: Cache might be done better, see for inspiration: https://github.com/godu/advent-of-code-2020/blob/46796832f59d185457a8edf8de043a54a451d688/.github/workflows/ci.yml
# with:
# path: |
# ~/.ghc
# ~/.stack
# ~/.stack-work
# key: ${{ runner.os }}-stack
- name: Set up Mariadb 🧰
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "mariadb-11.5"
- name: Setup PHP 🧰
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
extensions: mysqli
- name: build without test 🏗 🧪
uses: freckle/stack-action@v5
with:
stack-build-arguments: "--copy-bins --flag ampersand:buildAll"
test: false
- name: Upload artifacts (Windows)
uses: actions/upload-artifact@v4
with:
name: Windows-binaries
path: C:\Users\runneradmin\AppData\Roaming\local\bin\*