1111 description : " The branch name to base the release on"
1212 required : true
1313 type : string
14- asdfVersion :
14+ runtime_docker_image :
1515 type : string
16- required : false
17- default : " 0.18.0"
16+ required : true
1817 publish_packages :
1918 description : " comma separated list of package folders to publish to an npm registry"
2019 required : false
6059 required : false
6160 description : " NPM token to publish packages"
6261jobs :
63- install_semantic_release :
64- # Install asdf
65- # Use npm install -g to install semantic release and plugins globally
66- # # These are installed in the asdf npm version
67- # Bundle .asdf and upload as artifact
62+ tag_release :
6863 runs-on : ubuntu-22.04
64+ container :
65+ image : ghcr.io/nhsdigital/eps-devcontainers/${{ inputs.runtime_docker_image }}
66+ options : --user 1001:1001 --group-add 128
67+ defaults :
68+ run :
69+ shell : bash
70+ outputs :
71+ version_tag : ${{steps.output_version_tag.outputs.VERSION_TAG}}
72+ change_set_version : ${{ steps.output_change_set_version.outputs.CHANGE_SET_VERSION }}
73+ next_version_tag : ${{ steps.output_version_tag.outputs.NEXT_VERSION_TAG }}
6974 steps :
75+ - name : copy .tool-versions
76+ run : |
77+ cp /home/vscode/.tool-versions "$HOME/.tool-versions"
7078 - name : Checkout semantic-release workflow
7179 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
7280 with :
7381 repository : NHSDigital/eps-common-workflows
7482 sparse-checkout-cone-mode : false
83+ path : eps-common-workflows
7584 sparse-checkout : |
7685 package.json
7786 package-lock.json
7887 .tool-versions
7988 release.config.cjs
8089 releaseNotesTemplates/commit.hbs
81-
82- - name : Calculate asdf cache key
83- id : asdf_cache_key
84- run : |
85- base="${{ runner.os }}-asdf-${{ inputs.asdfVersion }}"
86- key="$base-${{ hashFiles('**/.tool-versions') }}"
87-
88- echo "base=$base" >> "$GITHUB_OUTPUT"
89- echo "key=$key" >> "$GITHUB_OUTPUT"
90-
91- - name : Calculate installed cache key
92- id : installed_cache_key
93- run : |
94- base="${{ steps.asdf_cache_key.outputs.key }}-npm"
95- key="$base-${{ hashFiles('**/package-lock.json') }}"
96-
97- echo "base=$base" >> "$GITHUB_OUTPUT"
98- echo "key=$key" >> "$GITHUB_OUTPUT"
99-
100- - name : Calculate artifact cache key
101- id : artifact_cache_key
102- run : |
103- base="${{ steps.installed_cache_key.outputs.key }}"
104- key="$base-artifact"
105-
106- echo "base=$base" >> "$GITHUB_OUTPUT"
107- echo "key=$key" >> "$GITHUB_OUTPUT"
108-
109- - name : Cache asdf artifact
110- id : asdf_artifact_cache
111- uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
112- with :
113- path : asdf.tar.gz
114- key : ${{ steps.artifact_cache_key.outputs.key }}
115- restore-keys : ${{ steps.artifact_cache_key.outputs.base }}*
116-
117- - name : Cache asdf with installed npm packages
118- if : ${{ steps.asdf_artifact_cache.outputs.cache-hit != 'true' }}
119- id : installed_cache
120- uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
121- with :
122- path : ~/.asdf
123- key : ${{ steps.installed_cache_key.outputs.key }}
124- restore-keys : ${{ steps.installed_cache_key.outputs.base }}*
125-
126- - name : Cache asdf
127- if : ${{ steps.installed_cache.outcome == 'success' && steps.installed_cache.outputs.cache-hit != 'true' }}
128- id : asdf_cache
129- uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
130- with :
131- path : ~/.asdf
132- key : ${{ steps.asdf_cache_key.outputs.key }}
133- restore-keys : |
134- ${{ steps.asdf_cache_key.outputs.base }}*
135-
136- - name : Install asdf dependencies in .tool-versions
137- if : ${{ steps.asdf_cache.outputs.cache-hit == 'false' || steps.asdf_cache.outcome != 'skipped' }}
138- uses : asdf-vm/actions/install@b7bcd026f18772e44fe1026d729e1611cc435d47
139- with :
140- asdf_version : ${{ inputs.asdfVersion }}
141-
14290 - name : Install semantic release dependencies globally
143- if : ${{ steps.installed_cache.outputs.cache-hit == 'false' || steps.installed_cache.outcome != 'skipped' }}
14491 run : |
92+ cd eps-common-workflows
14593 dependencies="$(jq -r '.devDependencies | to_entries | map("\(.key)@\(.value)") | join(" ")' package.json)"
14694 echo "Installing: $dependencies"
14795
14896 # shellcheck disable=SC2086
14997 npm install --global $dependencies
15098
151- - name : Prepare asdf artifact
152- if : ${{ steps.asdf_artifact_cache.outputs.cache-hit != 'true' }}
153- run : |
154- tar -czf asdf.tar.gz -C "$HOME" .asdf
155-
156- - name : Upload asdf artifact
157- uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
158- with :
159- name : asdf_artifact
160- path : asdf.tar.gz
161- overwrite : true
162-
163- - name : Prepare config artifact
164- run : |
165- mkdir -p config_artifact/releaseNotesTemplates
166- cp release.config.cjs config_artifact/
167- cp releaseNotesTemplates/commit.hbs config_artifact/releaseNotesTemplates/
168-
169- - name : Upload config artifact
170- uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
171- with :
172- name : config_artifact
173- path : config_artifact/
174- overwrite : true
175-
176- tag_release :
177- needs : install_semantic_release
178- runs-on : ubuntu-22.04
179- outputs :
180- version_tag : ${{steps.output_version_tag.outputs.VERSION_TAG}}
181- change_set_version : ${{ steps.output_change_set_version.outputs.CHANGE_SET_VERSION }}
182- next_version_tag : ${{ steps.output_version_tag.outputs.NEXT_VERSION_TAG }}
183- steps :
184- - name : Fetch asdf artifact
185- uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
186- with :
187- name : asdf_artifact
188- - name : Install asdf
189- uses : asdf-vm/actions/setup@b7bcd026f18772e44fe1026d729e1611cc435d47
190- with :
191- asdf_version : ${{ inputs.asdfVersion }}
192-
193- - name : Extract asdf
194- run : tar -xzf asdf.tar.gz -C "$HOME"
195-
196- - name : Setup node from cache
197- run : |
198- # Get installed node version (trim whitespace with xargs)
199- NODE_VER=$(asdf list nodejs | head -n1 | xargs)
200- NODE_DIR="$HOME/.asdf/installs/nodejs/$NODE_VER"
201-
202- echo "Using Node $NODE_VER from cache at $NODE_DIR"
203- asdf set -u nodejs "$NODE_VER"
204-
205- # Prepend binaries to path
206- echo "$NODE_DIR/bin" >> "$GITHUB_PATH"
207- echo "$NODE_DIR/lib/node_modules/.bin" >> "$GITHUB_PATH"
208-
209- # # Set node path to resolve packages
210- # NODE_PATH="$NODE_DIR/lib/node_modules"
211- # echo "NODE_PATH=$NODE_PATH" >> $GITHUB_ENV
212-
21399 - name : Clone calling repo
214100 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
215101 with :
@@ -225,29 +111,6 @@ jobs:
225111 env :
226112 BRANCH_NAME : ${{ inputs.branch_name }}
227113
228- - name : Fetch semantic-release config
229- uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
230- with :
231- name : config_artifact
232-
233- - name : Cache asdf
234- if : inputs.publish_packages != ''
235- uses : actions/cache@v5
236- with :
237- path : |
238- ~/.asdf
239- key : ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
240- restore-keys : |
241- ${{ runner.os }}-asdf-
242-
243- - name : Install asdf dependencies in .tool-versions
244- if : inputs.publish_packages != ''
245- uses : asdf-vm/actions/install@b7bcd026f18772e44fe1026d729e1611cc435d47
246- with :
247- asdf_version : ${{ inputs.asdfVersion }}
248- env :
249- PYTHON_CONFIGURE_OPTS : --enable-shared
250-
251114 - name : Install Dependencies and Build Package
252115 if : inputs.publish_packages != ''
253116 run : |
@@ -262,6 +125,11 @@ jobs:
262125 github-token : ${{ secrets.GITHUB_TOKEN }}
263126 repository : ${{ inputs.extra_artifact_repository }}
264127 run-id : ${{ inputs.extra_artifact_run_id }}
128+ - name : Copy semantic release config
129+ run : |
130+ cp eps-common-workflows/release.config.cjs .
131+ mkdir -p releaseNotesTemplates
132+ cp eps-common-workflows/releaseNotesTemplates/commit.hbs releaseNotesTemplates/
265133
266134 - name : Set VERSION_TAG based on dry_run flag
267135 id : output_version_tag
0 commit comments