Skip to content

Commit 24b922b

Browse files
authored
Fix: [AEA-0000] - fix release tagging (#2117)
## 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 fd71e6b commit 24b922b

File tree

14 files changed

+799
-6764
lines changed

14 files changed

+799
-6764
lines changed

.devcontainer/Dockerfile

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
FROM mcr.microsoft.com/devcontainers/base:ubuntu
22

3+
ARG TARGETARCH
4+
ENV TARGETARCH=${TARGETARCH}
5+
6+
ARG ASDF_VERSION
7+
COPY .tool-versions.asdf /tmp/.tool-versions.asdf
8+
39
RUN apt-get update \
410
&& export DEBIAN_FRONTEND=noninteractive \
511
&& apt-get -y dist-upgrade \
@@ -11,32 +17,42 @@ RUN apt-get update \
1117
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
1218
xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev
1319

14-
# install aws stuff
15-
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
20+
# Download correct AWS CLI for arch
21+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
22+
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
23+
else \
24+
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \
25+
fi && \
1626
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \
1727
/tmp/aws-cli/aws/install && \
18-
rm tmp/awscliv2.zip && \
19-
rm -rf /tmp/aws-cli
28+
rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli
2029

21-
RUN wget -O /tmp/aws-sam-cli.zip https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip && \
30+
# Download correct SAM CLI for arch
31+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
32+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip"; \
33+
else \
34+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"; \
35+
fi && \
2236
unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \
2337
/tmp/aws-sam-cli/install && \
24-
rm /tmp/aws-sam-cli.zip && \
25-
rm -rf /tmp/aws-sam-cli
38+
rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli
39+
40+
# Install ASDF
41+
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
42+
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; \
43+
tar -xvzf /tmp/asdf.tar.gz; \
44+
mv asdf /usr/bin
2645

2746
USER vscode
2847

29-
# Install ASDF
30-
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
31-
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
32-
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; \
48+
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
49+
RUN \
50+
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
51+
echo '. <(asdf completion bash)' >> ~/.bashrc; \
3352
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
3453
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
3554
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
3655

37-
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/prescriptionsforpatients/node_modules/.bin"
38-
39-
4056
# Install ASDF plugins
4157
RUN asdf plugin add python; \
4258
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \
@@ -54,9 +70,6 @@ WORKDIR /workspaces/prescriptionsforpatients
5470
ADD .tool-versions /workspaces/prescriptionsforpatients/.tool-versions
5571
ADD .tool-versions /home/vscode/.tool-versions
5672

57-
RUN asdf install; \
58-
asdf reshim python; \
59-
asdf reshim poetry; \
60-
asdf reshim nodejs; \
61-
asdf reshim java; \
62-
asdf direnv setup --shell bash --version 2.32.2;
73+
# install python before poetry to ensure correct python version is used
74+
RUN asdf install python; \
75+
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/ci.yml

Lines changed: 20 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -23,77 +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.11.3
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-
5234

53-
- name: Install asdf dependencies in .tool-versions
54-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
55-
with:
56-
asdf_branch: v0.11.3
57-
env:
58-
PYTHON_CONFIGURE_OPTS: --enable-shared
59-
60-
- name: Setting up .npmrc
61-
env:
62-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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
6340
run: |
64-
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
65-
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"
6643
67-
- name: Install node packages
68-
run: |
69-
make install-node
70-
71-
- name: Set VERSION_TAG env var to be short git SHA and get next tag version
72-
id: output_version_tag
73-
run: |
74-
VERSION_TAG=$(git rev-parse --short HEAD)
75-
npx semantic-release --dry-run > semantic-release-output.log
76-
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
77-
if [ -z "${NEXT_VERSION}" ]
78-
then
79-
echo "Could not get next tag. Here is the log from semantic-release"
80-
cat semantic-release-output.log
81-
exit 1
82-
fi
83-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
84-
if [ "${tagFormat}" = "null" ]
85-
then
86-
tagFormat="v\${version}"
87-
fi
88-
# disabling shellcheck as replace does not work
89-
# shellcheck disable=SC2001
90-
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
91-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
92-
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
93-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
94-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
95-
env:
96-
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@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
9754

9855
package_code:
9956
needs: tag_release

.github/workflows/pr_title_check.yml

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

.github/workflows/pull_request.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ env:
1010
jobs:
1111
quality_checks:
1212
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected]
13-
secrets:
13+
secrets:
1414
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1515

1616
pr_title_format_check:
17-
uses: ./.github/workflows/pr_title_check.yml
17+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/pr_title_check.yml@7abf2a3233d1b08d6566570dbde34b85daa47859
1818

1919
get_issue_number:
2020
runs-on: ubuntu-22.04
@@ -42,6 +42,34 @@ jobs:
4242
).data[0].number;
4343
}
4444
result-encoding: string
45+
get_asdf_version:
46+
runs-on: ubuntu-22.04
47+
outputs:
48+
asdf_version: ${{ steps.asdf-version.outputs.version }}
49+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v5
53+
54+
- name: Get asdf version
55+
id: asdf-version
56+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
57+
- name: Load config value
58+
id: load-config
59+
run: |
60+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
61+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
62+
63+
tag_release:
64+
needs: [get_asdf_version]
65+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2a3f4ab96e04b7547c4ee5b786745b98809c89be
66+
with:
67+
dry_run: true
68+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
69+
branch_name: ${{ github.event.pull_request.head.ref }}
70+
publish_package: false
71+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
72+
secrets: inherit
4573

4674
get_commit_id:
4775
runs-on: ubuntu-22.04
@@ -52,9 +80,9 @@ jobs:
5280
id: commit_id
5381
run: |
5482
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
55-
83+
5684
package_code:
57-
needs: get_issue_number
85+
needs: [get_issue_number, tag_release]
5886
uses: ./.github/workflows/sam_package_code.yml
5987

6088
release_code:

.github/workflows/release.yml

Lines changed: 20 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -19,95 +19,34 @@ jobs:
1919
run: |
2020
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
2121
22-
tag_release:
23-
needs: quality_checks
22+
get_asdf_version:
2423
runs-on: ubuntu-22.04
2524
outputs:
26-
version_tag: ${{steps.output_version_tag.outputs.VERSION_TAG}}
25+
asdf_version: ${{ steps.asdf-version.outputs.version }}
26+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
2727
steps:
2828
- name: Checkout code
2929
uses: actions/checkout@v5
30-
with:
31-
ref: main
32-
fetch-depth: 0
33-
34-
# using git commit sha for version of action to ensure we have stable version
35-
- name: Install asdf
36-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
37-
with:
38-
asdf_branch: v0.11.3
39-
40-
- name: Cache asdf
41-
uses: actions/cache@v4
42-
with:
43-
path: |
44-
~/.asdf
45-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
46-
restore-keys: |
47-
${{ runner.os }}-asdf-
48-
- name: Install asdf dependencies in .tool-versions
49-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
50-
with:
51-
asdf_branch: v0.11.3
52-
env:
53-
PYTHON_CONFIGURE_OPTS: --enable-shared
54-
55-
- name: Setting up .npmrc
56-
env:
57-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
run: |
59-
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
60-
echo "@NHSDigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
61-
62-
- name: Install node packages
63-
run: |
64-
make install-node
65-
66-
- name: Set VERSION_TAG env var to be short git SHA and get next tag version
67-
id: output_version_tag
68-
run: |
69-
VERSION_TAG=$(git rev-parse --short HEAD)
70-
NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
71-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
72-
if [ "${tagFormat}" = "null" ]
73-
then
74-
tagFormat="v\${version}"
75-
fi
76-
# disabling shellcheck as replace does not work
77-
# shellcheck disable=SC2001
78-
VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
79-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
80-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
81-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
82-
env:
83-
GITHUB_TOKEN: ${{ github.token }}
8430

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

11251
package_code:
11352
needs: tag_release

0 commit comments

Comments
 (0)