-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (183 loc) · 6.71 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
name: release
on:
workflow_dispatch:
inputs:
pre_release:
required: true
description: Create pre-release version, eq. 1.0.0-rc.0
type: boolean
default: false
push:
branches:
- release
jobs:
release_tag:
name: conventional changelog
runs-on: ubuntu-22.04
outputs:
changelog: ${{steps.changelog.outputs.clean_changelog}}
tag: ${{steps.changelog.outputs.tag}}
skipped: ${{steps.changelog.outputs.skipped}}
steps:
- name: checkout all history
# https://github.com/actions/checkout
uses: actions/checkout@v4
with:
# checkout whole history
fetch-depth: 0
- name: calculate new version and create changelog content
id: changelog
# https://github.com/TriPSs/conventional-changelog-action
uses: TriPSs/conventional-changelog-action@v5
with:
# you can also create separate token to trace action
github-token: "${{secrets.GITHUB_TOKEN}}"
# do not create changelog file, the content is used at next step for relase body
output-file: false
# do not create additional commit, just tag current commit with the version
skip-commit: true
# do not pull - we already checked out the selection we want to use for versioning in previous step
skip-git-pull: true
# skip tag push - it will not push but it will tag
git-push: false
# set to true to flag rc, eg 0.1.0-rc.0
pre-release: ${{inputs.pre_release}}
# initial version if no tag present
fallback-version: 0.0.1
log_release_tag:
needs: release_tag
name: log version output
runs-on: ubuntu-22.04
steps:
- name: info
run: |
echo skipped=${{needs.release_tag.outputs.skipped}}
echo tag=${{needs.release_tag.outputs.tag}}
frontend:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: frontend
uses: ./.github/workflows/_ghcr.yml
with:
ghcr_user: ${{github.actor}}
base_image_name: ghcr.io/research-software-directory/kin-rpd/frontend
image_tag: ${{needs.release_tag.outputs.tag}}
dockerfile: frontend/Dockerfile
docker_context: ./frontend
secrets:
token: ${{secrets.GITHUB_TOKEN}}
nginx:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: nginx
uses: ./.github/workflows/_ghcr.yml
with:
ghcr_user: ${{github.actor}}
base_image_name: ghcr.io/research-software-directory/kin-rpd/nginx
image_tag: ${{needs.release_tag.outputs.tag}}
dockerfile: nginx/Dockerfile
docker_context: ./nginx
secrets:
token: ${{secrets.GITHUB_TOKEN}}
documentation:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: documentation
uses: ./.github/workflows/_ghcr.yml
with:
ghcr_user: ${{github.actor}}
base_image_name: ghcr.io/research-software-directory/kin-rpd/documentation
image_tag: ${{needs.release_tag.outputs.tag}}
dockerfile: documentation/Dockerfile
docker_context: ./documentation
secrets:
token: ${{secrets.GITHUB_TOKEN}}
deployment_files:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: [release_tag,frontend,nginx,documentation]
name: create deployment.zip
runs-on: ubuntu-22.04
steps:
- name: checkout branch
# https://github.com/actions/checkout
uses: actions/checkout@v4
- name: update docker-compose.yml
run: |
echo replace :latest tag with ${{needs.release_tag.outputs.tag}}
sed -i -e 's/:latest/:${{needs.release_tag.outputs.tag}}/g' ./deployment/docker-compose.yml
cat ./deployment/docker-compose.yml
# - name: update CITATION.cff
# # use doublequotes in second replace "" to enable variable substitution with bash
# run: |
# echo replace version line
# sed -i -e 's/^version:.*/version: ${{needs.release_tag.outputs.tag}}/' CITATION.cff
# echo replace date
# sed -i -e "s/^date-released:.*/date-released: '$(date +%F)'/" CITATION.cff
# cat CITATION.cff
- name: zip deployment files
run: |
zip --junk-paths deployment.zip \
./deployment/docker-compose.yml \
./nginx/nginx.conf \
.env.example \
./deployment/README.md
- name: Upload deployment.zip
# https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v4
with:
name: deployment
path: deployment.zip
# - name: Upload CITATION.cff
# # https://github.com/actions/upload-artifact
# uses: actions/upload-artifact@v4
# with:
# name: citation
# path: CITATION.cff
release_draft:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: [ release_tag, deployment_files ]
name: create release draft
runs-on: ubuntu-22.04
steps:
- name: get deployment.zip
uses: actions/download-artifact@v4
with:
name: deployment
- name: validate info
run: |
echo show files
ls -lha
echo tag_name=${{needs.release_tag.outputs.tag}}
- name: create release draft
# https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@v2
env:
# The token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{needs.release_tag.outputs.tag}}
name: ${{needs.release_tag.outputs.tag}}
body: ${{needs.release_tag.outputs.changelog}}
draft: true
prerelease: false
files: deployment.zip
# citation:
# # it needs to be checked on string value
# if: needs.release_tag.outputs.skipped == 'false'
# needs: [ release_tag, deployment_files, release_draft ]
# name: citations
# uses: ./.github/workflows/_cff.yml
# with:
# artifact: citation
# branch: main
# commit_message: "chore(release): update citation file"
# secrets:
# # need to pass PAT using secrets prop to reusable workflow (module)
# # the secrets are not passed automatically to child modules
# # see https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/reusing-workflows#passing-inputs-and-secrets-to-a-reusable-workflow
# token: ${{ secrets.PAT_RELEASE }}