Skip to content

Commit dda35e3

Browse files
chore: move to common release tagging
1 parent cd9ef1a commit dda35e3

File tree

4 files changed

+64
-145
lines changed

4 files changed

+64
-145
lines changed

.github/config/settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TAG_FORMAT: "v${version}"

.github/workflows/ci.yml

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -23,80 +23,34 @@ jobs:
2323
run: |
2424
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
2525
26-
tag_release:
27-
needs: quality_checks
26+
get_asdf_version:
2827
runs-on: ubuntu-22.04
2928
outputs:
30-
version_tag: ${{ steps.output_version_tag.outputs.VERSION_TAG }}
29+
asdf_version: ${{ steps.asdf-version.outputs.version }}
30+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
3131
steps:
3232
- name: Checkout code
3333
uses: actions/checkout@v5
34-
with:
35-
ref: ${{ env.BRANCH_NAME }}
36-
fetch-depth: 0
3734

3835
- name: Get asdf version
3936
id: asdf-version
4037
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
41-
42-
# using git commit sha for version of action to ensure we have stable version
43-
- name: Install asdf
44-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
45-
with:
46-
asdf_version: ${{ steps.asdf-version.outputs.version }}
47-
48-
- name: Cache asdf
49-
uses: actions/cache@v4
50-
with:
51-
path: |
52-
~/.asdf
53-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
54-
restore-keys: |
55-
${{ runner.os }}-asdf-
56-
57-
- name: Install asdf dependencies in .tool-versions
58-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
59-
with:
60-
asdf_version: ${{ steps.asdf-version.outputs.version }}
61-
env:
62-
PYTHON_CONFIGURE_OPTS: --enable-shared
63-
64-
- name: Setting up .npmrc
65-
env:
66-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Load config value
39+
id: load-config
6740
run: |
68-
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
69-
echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
41+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
42+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
7043
71-
- name: Install Dependencies
72-
run: make install
73-
74-
- name: Set VERSION_TAG env var to be short git SHA and get next tag version
75-
id: output_version_tag
76-
run: |
77-
VERSION_TAG=$(git rev-parse --short HEAD)
78-
npx semantic-release --dry-run > semantic-release-output.log
79-
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
80-
if [ -z "${NEXT_VERSION}" ]
81-
then
82-
echo "Could not get next tag. Here is the log from semantic-release"
83-
cat semantic-release-output.log
84-
exit 1
85-
fi
86-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
87-
if [ "${tagFormat}" = "null" ]
88-
then
89-
tagFormat="v\${version}"
90-
fi
91-
# disabling shellcheck as replace does not work
92-
# shellcheck disable=SC2001
93-
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
94-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
95-
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
96-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
97-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
98-
env:
99-
GITHUB_TOKEN: ${{ github.token }}
44+
tag_release:
45+
needs: [quality_checks, get_commit_id, get_asdf_version]
46+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
47+
with:
48+
dry_run: true
49+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
50+
branch_name: main
51+
publish_package: false
52+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
53+
secrets: inherit
10054

10155
package_code:
10256
needs: [get_commit_id, tag_release]

.github/workflows/pull_request.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,35 @@ jobs:
4343
}
4444
result-encoding: string
4545

46+
get_asdf_version:
47+
runs-on: ubuntu-22.04
48+
outputs:
49+
asdf_version: ${{ steps.asdf-version.outputs.version }}
50+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v5
54+
55+
- name: Get asdf version
56+
id: asdf-version
57+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
58+
- name: Load config value
59+
id: load-config
60+
run: |
61+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
62+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
63+
64+
tag_release:
65+
needs: [get_asdf_version]
66+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
67+
with:
68+
dry_run: true
69+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
70+
branch_name: ${{ github.event.pull_request.head.ref }}
71+
publish_package: false
72+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
73+
secrets: inherit
74+
4675
get_commit_id:
4776
runs-on: ubuntu-22.04
4877
outputs:

.github/workflows/release.yml

Lines changed: 17 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -22,100 +22,35 @@ jobs:
2222
run: |
2323
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
2424
25-
tag_release:
26-
needs: quality_checks
25+
get_asdf_version:
2726
runs-on: ubuntu-22.04
2827
outputs:
29-
version_tag: ${{ steps.output_version_tag.outputs.VERSION_TAG }}
28+
asdf_version: ${{ steps.asdf-version.outputs.version }}
29+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
3030
steps:
3131
- name: Checkout code
3232
uses: actions/checkout@v5
33-
with:
34-
ref: ${{ env.BRANCH_NAME }}
35-
fetch-depth: 0
3633

3734
- name: Get asdf version
3835
id: asdf-version
3936
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
4037

41-
# using git commit sha for version of action to ensure we have stable version
42-
- name: Install asdf
43-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
44-
with:
45-
asdf_version: ${{ steps.asdf-version.outputs.version }}
46-
47-
- name: Cache asdf
48-
uses: actions/cache@v4
49-
with:
50-
path: |
51-
~/.asdf
52-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
53-
restore-keys: |
54-
${{ runner.os }}-asdf-
55-
56-
- name: Install asdf dependencies in .tool-versions
57-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
58-
with:
59-
asdf_version: ${{ steps.asdf-version.outputs.version }}
60-
env:
61-
PYTHON_CONFIGURE_OPTS: --enable-shared
62-
63-
- name: Setting up .npmrc
64-
env:
65-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66-
run: |
67-
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
68-
echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
69-
70-
- name: Install dependencies
71-
run: |
72-
make install
73-
74-
- name: Set VERSION_TAG to be next tag varsion
75-
id: output_version_tag
76-
run: |
77-
NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
78-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
79-
if [ "${tagFormat}" = "null" ]
80-
then
81-
tagFormat="v\${version}"
82-
fi
83-
# disabling shellcheck as replace does not work
84-
# shellcheck disable=SC2001
85-
VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
86-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
87-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
88-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
89-
env:
90-
GITHUB_TOKEN: ${{ github.token }}
91-
92-
- name: tag release
93-
env:
94-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Load config value
39+
id: load-config
9540
run: |
96-
npx semantic-release
97-
98-
- name: Get release for editing
99-
id: get_release
100-
# version 1.2.4
101-
uses: cardinalby/git-get-release-action@5172c3a026600b1d459b117738c605fabc9e4e44
102-
env:
103-
GITHUB_TOKEN: ${{ github.token }}
104-
with:
105-
tag: ${{ env.VERSION_TAG }}
41+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
42+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
10643
107-
- name: Edit Release
108-
# version 1.2.0
109-
uses: irongut/EditRelease@ccf529ad26dddf9996e7dd0f24ca5da4ea507cc2
110-
with:
111-
token: ${{ secrets.GITHUB_TOKEN }}
112-
id: ${{ steps.get_release.outputs.id }}
113-
body: |
114-
## Info
115-
[See code diff](${{ github.event.compare }})
116-
[Release workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
117-
118-
It was initialized by [${{ github.event.sender.login }}](${{ github.event.sender.html_url }})
44+
tag_release:
45+
needs: [quality_checks, get_commit_id, get_asdf_version]
46+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
47+
with:
48+
dry_run: false
49+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
50+
branch_name: main
51+
publish_package: false
52+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
53+
secrets: inherit
11954

12055
package_code:
12156
needs: [get_commit_id, tag_release]

0 commit comments

Comments
 (0)