Skip to content

Commit b1d8ab5

Browse files
authored
Fix: [AEA-0000] - fix release tagging (#1446)
## Summary - Routine Change ### Details - use common workflow for pr title check - use common workflow for release tagging - use .tool-versions.asdf for asdf version
1 parent 4802caf commit b1d8ab5

File tree

13 files changed

+1242
-7045
lines changed

13 files changed

+1242
-7045
lines changed

.devcontainer/Dockerfile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ FROM mcr.microsoft.com/devcontainers/base:ubuntu
22
ARG TARGETARCH
33
ENV TARGETARCH=${TARGETARCH}
44

5+
ARG ASDF_VERSION
6+
COPY .tool-versions.asdf /tmp/.tool-versions.asdf
7+
58
# Add amd64 architecture if on arm64
69
RUN if [ "$TARGETARCH" == "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then dpkg --add-architecture amd64; fi
710

@@ -27,19 +30,22 @@ RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
2730
/tmp/aws-cli/aws/install && \
2831
rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli
2932

33+
# Install ASDF
34+
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
35+
wget -O /tmp/asdf.tar.gz https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-amd64.tar.gz; \
36+
tar -xvzf /tmp/asdf.tar.gz; \
37+
mv asdf /usr/bin
38+
3039
USER vscode
3140

32-
# Install ASDF
33-
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
34-
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
35-
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; \
41+
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
42+
RUN \
43+
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
44+
echo '. <(asdf completion bash)' >> ~/.bashrc; \
3645
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
3746
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
3847
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
3948

40-
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/eps-prescription-tracker-ui/node_modules/.bin"
41-
42-
4349
# Install ASDF plugins
4450
RUN asdf plugin add python; \
4551
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \
@@ -54,8 +60,6 @@ WORKDIR /workspaces/eps-prescription-tracker-ui
5460
ADD .tool-versions /workspaces/eps-prescription-tracker-ui/.tool-versions
5561
ADD .tool-versions /home/vscode/.tool-versions
5662

57-
RUN asdf install; \
58-
asdf reshim python; \
59-
asdf reshim poetry; \
60-
asdf reshim nodejs; \
61-
asdf direnv setup --shell bash --version 2.32.2;
63+
# install python before poetry to ensure correct python version is used
64+
RUN asdf install python; \
65+
asdf install

.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}-beta"

.github/workflows/cdk_package_code.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
required: true
1111
type: string
1212

13-
1413
jobs:
1514
package_code:
1615
runs-on: ubuntu-22.04
@@ -24,25 +23,30 @@ jobs:
2423
with:
2524
ref: ${{ env.BRANCH_NAME }}
2625

26+
# using git commit sha for version of action to ensure we have stable version
27+
- name: Get asdf version
28+
id: asdf-version
29+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
30+
2731
# using git commit sha for version of action to ensure we have stable version
2832
- name: Install asdf
2933
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
3034
with:
31-
asdf_branch: v0.14.1
32-
35+
asdf_version: ${{ steps.asdf-version.outputs.version }}
36+
3337
- name: Cache asdf
3438
uses: actions/cache@v4
3539
with:
3640
path: |
3741
~/.asdf
38-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
42+
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}-${{ steps.asdf-version.outputs.version }}
3943
restore-keys: |
40-
${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
44+
${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}-${{ steps.asdf-version.outputs.version }}
4145
4246
- name: Install asdf dependencies in .tool-versions
4347
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
4448
with:
45-
asdf_branch: v0.14.1
49+
asdf_version: ${{ steps.asdf-version.outputs.version }}
4650
env:
4751
PYTHON_CONFIGURE_OPTS: --enable-shared
4852

@@ -51,7 +55,7 @@ jobs:
5155
make install
5256
make compile-node
5357
54-
- name: 'Tar files'
58+
- name: "Tar files"
5559
run: |
5660
tar -rf artifact.tar \
5761
.tool-versions \

.github/workflows/ci.yml

Lines changed: 22 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -23,69 +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
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-${{ hashFiles('**/.tool-versions') }}
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
5934

60-
- name: Install Dependencies
61-
run: make install
62-
63-
- name: Set VERSION_TAG env var to be short git SHA and get next tag varsion
64-
id: output_version_tag
35+
- name: Get asdf version
36+
id: asdf-version
37+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
38+
- name: Load config value
39+
id: load-config
6540
run: |
66-
VERSION_TAG=$(git rev-parse --short HEAD)
67-
npx semantic-release --dry-run > semantic-release-output.log
68-
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
69-
if [ -z "${NEXT_VERSION}" ]
70-
then
71-
echo "Could not get next tag. Here is the log from semantic-release"
72-
cat semantic-release-output.log
73-
exit 1
74-
fi
75-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
76-
if [ "${tagFormat}" = "null" ]
77-
then
78-
tagFormat="v\${version}"
79-
fi
80-
# disabling shellcheck as replace does not work
81-
# shellcheck disable=SC2001
82-
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
83-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
84-
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
85-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
86-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
87-
env:
88-
GITHUB_TOKEN: ${{ github.token }}
41+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
42+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
43+
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@2a3f4ab96e04b7547c4ee5b786745b98809c89be
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
8954

9055
package_code:
9156
needs: [tag_release, get_commit_id]
@@ -134,7 +99,7 @@ jobs:
13499
CREATE_INT_RC_RELEASE_NOTES: false
135100
IS_PULL_REQUEST: false
136101
secrets: inherit
137-
102+
138103
release_qa:
139104
needs: [tag_release, release_dev, package_code, get_commit_id]
140105
uses: ./.github/workflows/release_all_stacks.yml

.github/workflows/pr_title_check.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/pull_request.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
run: echo "Skipping QC gate per commit message."
9595

9696
pr_title_format_check:
97-
uses: ./.github/workflows/pr_title_check.yml
97+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/pr_title_check.yml@7abf2a3233d1b08d6566570dbde34b85daa47859
9898

9999
get_issue_number:
100100
runs-on: ubuntu-22.04
@@ -122,6 +122,35 @@ jobs:
122122
}
123123
result-encoding: string
124124

125+
get_asdf_version:
126+
runs-on: ubuntu-22.04
127+
outputs:
128+
asdf_version: ${{ steps.asdf-version.outputs.version }}
129+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
130+
steps:
131+
- name: Checkout code
132+
uses: actions/checkout@v5
133+
134+
- name: Get asdf version
135+
id: asdf-version
136+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
137+
- name: Load config value
138+
id: load-config
139+
run: |
140+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
141+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
142+
143+
tag_release:
144+
needs: [get_asdf_version]
145+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2a3f4ab96e04b7547c4ee5b786745b98809c89be
146+
with:
147+
dry_run: true
148+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
149+
branch_name: ${{ github.event.pull_request.head.ref }}
150+
publish_package: false
151+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
152+
secrets: inherit
153+
125154
get_commit_id:
126155
runs-on: ubuntu-22.04
127156
outputs:

.github/workflows/release.yml

Lines changed: 20 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -22,89 +22,34 @@ 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
36-
37-
# using git commit sha for version of action to ensure we have stable version
38-
- name: Install asdf
39-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
40-
with:
41-
asdf_branch: v0.14.1
42-
43-
- name: Cache asdf
44-
uses: actions/cache@v4
45-
with:
46-
path: |
47-
~/.asdf
48-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
49-
restore-keys: |
50-
${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
51-
52-
- name: Install asdf dependencies in .tool-versions
53-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
54-
with:
55-
asdf_branch: v0.14.1
56-
env:
57-
PYTHON_CONFIGURE_OPTS: --enable-shared
58-
59-
- name: Install dependencies
60-
run: |
61-
make install
62-
63-
- name: Set VERSION_TAG to be next tag varsion
64-
id: output_version_tag
65-
run: |
66-
NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
67-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
68-
if [ "${tagFormat}" = "null" ]
69-
then
70-
tagFormat="v\${version}"
71-
fi
72-
# disabling shellcheck as replace does not work
73-
# shellcheck disable=SC2001
74-
VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
75-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
76-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
77-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
78-
env:
79-
GITHUB_TOKEN: ${{ github.token }}
8033

81-
- name: tag release
82-
env:
83-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Get asdf version
35+
id: asdf-version
36+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
37+
- name: Load config value
38+
id: load-config
8439
run: |
85-
npx semantic-release
40+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
41+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
8642
87-
- name: Get release for editing
88-
id: get_release
89-
# version 1.2.4
90-
uses: cardinalby/git-get-release-action@5172c3a026600b1d459b117738c605fabc9e4e44
91-
env:
92-
GITHUB_TOKEN: ${{ github.token }}
93-
with:
94-
tag: ${{ env.VERSION_TAG }}
95-
96-
- name: Edit Release
97-
# version 1.2.0
98-
uses: irongut/EditRelease@ccf529ad26dddf9996e7dd0f24ca5da4ea507cc2
99-
with:
100-
token: ${{ secrets.GITHUB_TOKEN }}
101-
id: ${{ steps.get_release.outputs.id }}
102-
body: |
103-
## Info
104-
[See code diff](${{ github.event.compare }})
105-
[Release workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
106-
107-
It was initialized by [${{ github.event.sender.login }}](${{ github.event.sender.html_url }})
43+
tag_release:
44+
needs: [quality_checks, get_commit_id, get_asdf_version]
45+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2a3f4ab96e04b7547c4ee5b786745b98809c89be
46+
with:
47+
dry_run: false
48+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
49+
branch_name: main
50+
publish_package: false
51+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
52+
secrets: inherit
10853

10954
package_code:
11055
needs: [tag_release, get_commit_id]

0 commit comments

Comments
 (0)