Skip to content

Commit 9d36b4b

Browse files
chore: tagging fix until unified method
1 parent 84b47be commit 9d36b4b

File tree

5 files changed

+87
-161
lines changed

5 files changed

+87
-161
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/cdk_package_code.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Install asdf
3131
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
3232
with:
33-
asdf_branch: v0.14.1
33+
asdf_branch: v0.18.0
3434

3535
- name: Cache asdf
3636
uses: actions/cache@v4
@@ -44,7 +44,7 @@ jobs:
4444
- name: Install asdf dependencies in .tool-versions
4545
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
4646
with:
47-
asdf_branch: v0.14.1
47+
asdf_branch: v0.18.0
4848
env:
4949
PYTHON_CONFIGURE_OPTS: --enable-shared
5050

.github/workflows/ci.yml

Lines changed: 31 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,30 @@ env:
88
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
99

1010
jobs:
11+
get_asdf_version:
12+
runs-on: ubuntu-22.04
13+
outputs:
14+
asdf_version: ${{ steps.asdf-version.outputs.version }}
15+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v5
19+
20+
- name: Get asdf version
21+
id: asdf-version
22+
run: echo "version=0.18.0" >> "$GITHUB_OUTPUT"
23+
24+
- name: Load config value
25+
id: load-config
26+
run: |
27+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
28+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
29+
1130
quality_checks:
1231
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected]
32+
needs: [get_asdf_version]
33+
with:
34+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
1335
secrets:
1436
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1537

@@ -24,75 +46,15 @@ jobs:
2446
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
2547
2648
tag_release:
27-
needs: quality_checks
28-
runs-on: ubuntu-22.04
29-
outputs:
30-
version_tag: ${{ steps.output_version_tag.outputs.VERSION_TAG }}
31-
steps:
32-
- name: Checkout code
33-
uses: actions/checkout@v5
34-
with:
35-
ref: ${{ env.BRANCH_NAME }}
36-
fetch-depth: 0
37-
38-
# using git commit sha for version of action to ensure we have stable version
39-
- name: Install asdf
40-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
41-
with:
42-
asdf_branch: v0.14.1
43-
44-
- name: Cache asdf
45-
uses: actions/cache@v4
46-
with:
47-
path: |
48-
~/.asdf
49-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
50-
restore-keys: |
51-
${{ runner.os }}-asdf-
52-
53-
- name: Install asdf dependencies in .tool-versions
54-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
55-
with:
56-
asdf_branch: v0.14.1
57-
env:
58-
PYTHON_CONFIGURE_OPTS: --enable-shared
59-
60-
- name: Setting up .npmrc
61-
env:
62-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
run: |
64-
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
65-
echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
66-
67-
- name: Install Dependencies
68-
run: make install
69-
70-
- name: Set VERSION_TAG env var to be short git SHA and get next tag varsion
71-
id: output_version_tag
72-
run: |
73-
VERSION_TAG=$(git rev-parse --short HEAD)
74-
npx semantic-release --dry-run > semantic-release-output.log
75-
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
76-
if [ -z "${NEXT_VERSION}" ]
77-
then
78-
echo "Could not get next tag. Here is the log from semantic-release"
79-
cat semantic-release-output.log
80-
exit 1
81-
fi
82-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
83-
if [ "${tagFormat}" = "null" ]
84-
then
85-
tagFormat="v\${version}"
86-
fi
87-
# disabling shellcheck as replace does not work
88-
# shellcheck disable=SC2001
89-
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
90-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
91-
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
92-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
93-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
94-
env:
95-
GITHUB_TOKEN: ${{ github.token }}
49+
needs: [quality_checks, get_commit_id, get_asdf_version]
50+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
51+
with:
52+
dry_run: true
53+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
54+
branch_name: main
55+
publish_package: false
56+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
57+
secrets: inherit
9658

9759
package_code:
9860
needs: [get_commit_id, tag_release]

.github/workflows/pull_request.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,30 @@ env:
88
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
99

1010
jobs:
11+
get_asdf_version:
12+
runs-on: ubuntu-22.04
13+
outputs:
14+
asdf_version: ${{ steps.asdf-version.outputs.version }}
15+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v5
19+
20+
- name: Get asdf version
21+
id: asdf-version
22+
run: echo "version=0.18.0" >> "$GITHUB_OUTPUT"
23+
24+
- name: Load config value
25+
id: load-config
26+
run: |
27+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
28+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
29+
1130
quality_checks:
1231
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected]
32+
needs: [get_asdf_version]
33+
with:
34+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
1335
secrets:
1436
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1537

.github/workflows/release.yml

Lines changed: 31 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,30 @@ env:
1414
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
1515

1616
jobs:
17+
get_asdf_version:
18+
runs-on: ubuntu-22.04
19+
outputs:
20+
asdf_version: ${{ steps.asdf-version.outputs.version }}
21+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v5
25+
26+
- name: Get asdf version
27+
id: asdf-version
28+
run: echo "version=0.18.0" >> "$GITHUB_OUTPUT"
29+
30+
- name: Load config value
31+
id: load-config
32+
run: |
33+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
34+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
35+
1736
quality_checks:
1837
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected]
38+
needs: [get_asdf_version]
39+
with:
40+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
1941
secrets:
2042
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2143

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

12465
package_code:
12566
needs: [tag_release, get_commit_id]

0 commit comments

Comments
 (0)