Skip to content

Commit a1a9c85

Browse files
authored
Fix: [AEA-0000] - fix release tagging (#455)
## 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 6f8f0a4 commit a1a9c85

File tree

11 files changed

+2804
-9700
lines changed

11 files changed

+2804
-9700
lines changed

.devcontainer/Dockerfile

Lines changed: 21 additions & 11 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
# System updates
410
RUN apt-get update \
511
&& export DEBIAN_FRONTEND=noninteractive \
@@ -11,14 +17,21 @@ RUN apt-get update \
1117
RUN apt-get -y install --no-install-recommends \
1218
libffi-dev libsqlite3-dev
1319

14-
USER vscode
15-
1620
# Install ASDF
17-
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
18-
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
19-
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc;
21+
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
22+
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; \
23+
tar -xvzf /tmp/asdf.tar.gz; \
24+
mv asdf /usr/bin
25+
26+
USER vscode
2027

21-
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/nhs-fhir-middy-error-handler/node_modules/.bin"
28+
ENV PATH="$PATH:/home/vscode/.asdf/shims/:/home/vscode/.asdf/bin/:/workspaces/nhs-fhir-middy-error-handler/node_modules/.bin:$PATH"
29+
RUN \
30+
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
31+
echo '. <(asdf completion bash)' >> ~/.bashrc; \
32+
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
33+
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
34+
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
2235

2336
# Install ASDF plugins
2437
RUN asdf plugin add python; \
@@ -32,8 +45,5 @@ WORKDIR /workspaces/nhs-fhir-middy-error-handler
3245
ADD .tool-versions /workspaces/nhs-fhir-middy-error-handler/.tool-versions
3346
ADD .tool-versions /home/vscode/.tool-versions
3447

35-
RUN asdf install; \
36-
asdf reshim python; \
37-
asdf reshim poetry; \
38-
asdf reshim nodejs; \
39-
asdf direnv setup --shell bash --version 2.32.2;
48+
RUN asdf install python; \
49+
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}"

.github/workflows/ci.yml

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,67 +9,31 @@ jobs:
99
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected]
1010
secrets:
1111
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
12-
13-
tag_release:
14-
needs: quality_checks
12+
get_asdf_version:
1513
runs-on: ubuntu-22.04
14+
outputs:
15+
asdf_version: ${{ steps.asdf-version.outputs.version }}
16+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
1617
steps:
1718
- name: Checkout code
1819
uses: actions/checkout@v5
19-
with:
20-
ref: ${{ env.BRANCH_NAME }}
21-
fetch-depth: 0
22-
23-
# using git commit sha for version of action to ensure we have stable version
24-
- name: Install asdf
25-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
26-
with:
27-
asdf_branch: v0.11.3
28-
29-
- name: Cache asdf
30-
uses: actions/cache@v4
31-
with:
32-
path: |
33-
~/.asdf
34-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
35-
restore-keys: |
36-
${{ runner.os }}-asdf-
3720

38-
- name: Install asdf dependencies in .tool-versions
39-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
40-
with:
41-
asdf_branch: v0.11.3
42-
env:
43-
PYTHON_CONFIGURE_OPTS: --enable-shared
44-
45-
- name: Install node packages
21+
- name: Get asdf version
22+
id: asdf-version
23+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
24+
- name: Load config value
25+
id: load-config
4626
run: |
47-
make install-node
27+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
28+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
4829
49-
- name: Set VERSION_TAG env var to be short git SHA and get next tag varsion
50-
id: output_version_tag
51-
run: |
52-
VERSION_TAG=$(git rev-parse --short HEAD)
53-
npx semantic-release --dry-run > semantic-release-output.log
54-
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
55-
if [ -z "${NEXT_VERSION}" ]
56-
then
57-
echo "Could not get next tag. Here is the log from semantic-release"
58-
cat semantic-release-output.log
59-
exit 1
60-
fi
61-
tagFormat=$(node -e "const config=require('./release.config.cjs'); console.log(config.tagFormat)")
62-
if [ "${tagFormat}" = "null" ]
63-
then
64-
tagFormat="v\${version}"
65-
fi
66-
# disabling shellcheck as replace does not work
67-
# shellcheck disable=SC2001
68-
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
69-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
70-
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
71-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
72-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
73-
env:
74-
GITHUB_TOKEN: ${{ github.token }}
75-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30+
tag_release:
31+
needs: [quality_checks, get_asdf_version]
32+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2290b8f50ea4473c6e1b2249891ae1ba274d83c2
33+
with:
34+
dry_run: true
35+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
36+
branch_name: main
37+
publish_package: false
38+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
39+
secrets: inherit

.github/workflows/pr_title_check.yml

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

.github/workflows/pull_request.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,33 @@ jobs:
1111
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1212

1313
pr_title_format_check:
14-
uses: ./.github/workflows/pr_title_check.yml
14+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/pr_title_check.yml@7abf2a3233d1b08d6566570dbde34b85daa47859
15+
16+
get_asdf_version:
17+
runs-on: ubuntu-22.04
18+
outputs:
19+
asdf_version: ${{ steps.asdf-version.outputs.version }}
20+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v5
24+
25+
- name: Get asdf version
26+
id: asdf-version
27+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
28+
- name: Load config value
29+
id: load-config
30+
run: |
31+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
32+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
33+
34+
tag_release:
35+
needs: [get_asdf_version]
36+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2290b8f50ea4473c6e1b2249891ae1ba274d83c2
37+
with:
38+
dry_run: true
39+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
40+
branch_name: ${{ github.event.pull_request.head.ref }}
41+
publish_package: false
42+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
43+
secrets: inherit

.github/workflows/release.yml

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,30 @@ jobs:
1111
secrets:
1212
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1313

14-
release:
15-
needs: quality_checks
14+
get_asdf_version:
1615
runs-on: ubuntu-22.04
16+
outputs:
17+
asdf_version: ${{ steps.asdf-version.outputs.version }}
18+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
1719
steps:
1820
- name: Checkout code
1921
uses: actions/checkout@v5
20-
with:
21-
ref: main
22-
fetch-depth: 0
2322

24-
# using git commit sha for version of action to ensure we have stable version
25-
- name: Install asdf
26-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
27-
with:
28-
asdf_branch: v0.11.3
29-
30-
- name: Cache asdf
31-
uses: actions/cache@v4
32-
with:
33-
path: |
34-
~/.asdf
35-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
36-
restore-keys: |
37-
${{ runner.os }}-asdf-
38-
39-
- name: Install asdf dependencies in .tool-versions
40-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
41-
with:
42-
asdf_branch: v0.11.3
43-
env:
44-
PYTHON_CONFIGURE_OPTS: --enable-shared
45-
46-
- name: make install
47-
run: |
48-
make install
49-
50-
- name: Build
51-
run: make build
52-
53-
# use semantic-release to determine the next version number
54-
- name: Release
55-
env:
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
23+
- name: Get asdf version
24+
id: asdf-version
25+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
26+
- name: Load config value
27+
id: load-config
5828
run: |
59-
npx semantic-release
29+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
30+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
31+
tag_release:
32+
needs: [quality_checks, get_asdf_version]
33+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2290b8f50ea4473c6e1b2249891ae1ba274d83c2
34+
with:
35+
dry_run: false
36+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
37+
branch_name: main
38+
publish_package: true
39+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
40+
secrets: inherit

.tool-versions.asdf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# define the .asdf-version to use here
2+
0.18.0

0 commit comments

Comments
 (0)