forked from ocaml-sf/learn-ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (228 loc) · 10.4 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
229
230
231
232
233
name: Release
# Credits: workflow inspired from
# https://github.com/grain-lang/binaryen.ml/blob/master/.github/workflows/release.yml
# then slightly adapted, using:
# - https://github.com/googleapis/release-please#readme
# - https://github.com/google-github-actions/release-please-action/blob/main/action.yml
# - https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_run
# - https://docs.github.com/en/actions/advanced-guides/storing-workflow-data-as-artifacts
# - https://github.com/dawidd6/action-download-artifact#readme
# - https://hub.github.com/hub-release.1.html
on:
workflow_run:
workflows: ["Generate static binaries"]
branches: ["master"]
types: ["completed"]
# TODO: dispatch?
jobs:
release-please:
name: Create Release
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository == 'ocaml-sf/learn-ocaml'}}
outputs:
release_created: ${{ steps.release.outputs.release_created }}
upload_url: ${{ steps.release.outputs.upload_url }}
tag_name: ${{ steps.release.outputs.tag_name }}
body: ${{ steps.release.outputs.body }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: ocaml
package-name: learn-ocaml
bump-minor-pre-major: false
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"revert","section":"Reverts","hidden":false},{"type":"perf","section":"Performance Improvements","hidden":false},{"type":"refactor","section":"Code Refactoring","hidden":false},{"type":"deps","section":"Dependencies","hidden":false},{"type":"build","section":"Build System","hidden":false},{"type":"test","section":"Tests","hidden":false},{"type":"ci","section":"CI/CD","hidden":false},{"type":"docs","section":"Documentation","hidden":false},{"type":"style","section":"Style","hidden":false},{"type":"chore","section":"Miscellaneous Chores","hidden":true}]'
add-binaries:
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
name: Add archive and binaries to release
runs-on: ubuntu-latest
steps:
- name: Check out the repo
# Mandatory step (otherwise, gh could raise "fatal: Not a git repository")
uses: actions/checkout@v4
- name: Download workflow artifacts
# cf. https://github.com/actions/download-artifact/issues/3
uses: dawidd6/action-download-artifact@v2
with:
workflow: static-builds.yml
workflow_conclusion: success
commit: ${{ github.sha }}
path: artifacts
- name: Unpack workflow artifacts
run: |
cd artifacts
mkdir -v target
dist=(linux darwin)
artifact() { printf "learn-ocaml-%s-x86_64.tar.gz" "$d"; }
for d in "${dist[@]}"; do
mkdir -v -- "$d"
( cd "$d" && tar xvzf "../$(artifact "$d")/$(artifact "$d")" )
bin=(./learn-ocaml-client ./learn-ocaml-server ./learn-ocaml)
for b in "${bin[@]}"; do
mv -v -- "$d/$b" "target/$b-$d-x86_64"
done
done
mv -v -- learn-ocaml-www.zip target/learn-ocaml-www.zip
- name: Add binaries to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh release -R ocaml-sf/learn-ocaml upload "${{ needs.release-please.outputs.tag_name }}" $(find artifacts/target -type f -printf "%p ")
call-opam-publish:
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
uses: ./.github/workflows/opam-publish.yml
with:
release: "true"
tag_name: ${{ needs.release-please.outputs.tag_name }}
body: |
Cc @erikmd @yurug @AltGr FYI
${{ needs.release-please.outputs.body }}
secrets:
OPAM_RELEASE: ${{ secrets.OPAM_RELEASE }}
# Note: you may want to update the jobs below and deploy-master.yml at once
push_server:
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
name: Push learn-ocaml image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Get tag name
run: tag="${{ needs.release-please.outputs.tag_name }}"; echo "::set-output name=tag::${tag#v}"
id: tag
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
uses: docker/setup-buildx-action@v2
with:
driver: "docker"
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Prepare
id: prep
run: |
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
- name: Push to Docker Hub
# cf. https://github.com/docker/build-push-action#customizing
# and https://github.com/docker/build-push-action/pull/119
uses: docker/build-push-action@v4
with:
pull: true
push: true
tags: |
ocamlsf/learn-ocaml:latest
ocamlsf/learn-ocaml:${{ steps.tag.outputs.tag }}
labels: |
org.opencontainers.image.title=learn-ocaml
org.opencontainers.image.description=learn-ocaml app manager
org.opencontainers.image.url=https://ocaml-sf.org/
org.opencontainers.image.vendor=The OCaml Software Foundation
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ steps.tag.outputs.tag }}
org.opencontainers.image.revision=${{ github.sha }}
push_client:
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
name: Push learn-ocaml-client image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Get tag name
run: tag="${{ needs.release-please.outputs.tag_name }}"; echo "::set-output name=tag::${tag#v}"
id: tag
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
uses: docker/setup-buildx-action@v2
with:
driver: "docker"
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Prepare
id: prep
run: |
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
- name: Push to Docker Hub
# cf. https://github.com/docker/build-push-action#customizing
# and https://github.com/docker/build-push-action/pull/119
uses: docker/build-push-action@v4
with:
pull: true
# load: true # implied by "driver: docker"
push: true
target: client
tags: |
ocamlsf/learn-ocaml-client:latest
ocamlsf/learn-ocaml-client:${{ steps.tag.outputs.tag }}
labels: |
org.opencontainers.image.title=learn-ocaml-client
org.opencontainers.image.description=learn-ocaml command-line client
org.opencontainers.image.url=https://ocaml-sf.org/
org.opencontainers.image.vendor=The OCaml Software Foundation
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ steps.tag.outputs.tag }}
org.opencontainers.image.revision=${{ github.sha }}
push_emacs_client:
needs:
- release-please
- push_client
if: ${{ needs.release-please.outputs.release_created }}
name: Push emacs-learn-ocaml-client image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Get tag name
run: tag="${{ needs.release-please.outputs.tag_name }}"; echo "::set-output name=tag::${tag#v}"
id: tag
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
uses: docker/setup-buildx-action@v2
with:
driver: "docker"
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Prepare
id: prep
run: |
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
- name: Push to Docker Hub
# cf. https://github.com/docker/build-push-action#customizing
# and https://github.com/docker/build-push-action/pull/119
uses: docker/build-push-action@v4
with:
pull: false # because of the previous "load: true"
push: true
context: ci/docker-emacs-learn-ocaml-client
build-args: |
base=ocamlsf/learn-ocaml-client
version=${{ steps.tag.outputs.tag }}
tags: |
ocamlsf/emacs-learn-ocaml-client:latest
ocamlsf/emacs-learn-ocaml-client:${{ steps.tag.outputs.tag }}
labels: |
org.opencontainers.image.title=learn-ocaml-client with emacs
org.opencontainers.image.description=learn-ocaml command-line client with emacs
org.opencontainers.image.url=https://ocaml-sf.org/
org.opencontainers.image.vendor=The OCaml Software Foundation
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ steps.tag.outputs.tag }}
org.opencontainers.image.revision=${{ github.sha }}