Skip to content

Commit 4d0a61d

Browse files
authored
Fix: [AEA-0000] - fix release tag (#532)
## 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 d3c41a8 commit 4d0a61d

File tree

11 files changed

+4359
-10956
lines changed

11 files changed

+4359
-10956
lines changed

.devcontainer/Dockerfile

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

3+
4+
ARG TARGETARCH
5+
ENV TARGETARCH=${TARGETARCH}
6+
7+
ARG ASDF_VERSION
8+
COPY .tool-versions.asdf /tmp/.tool-versions.asdf
9+
310
# System updates
411
RUN apt-get update \
512
&& export DEBIAN_FRONTEND=noninteractive \
@@ -11,12 +18,14 @@ RUN apt-get update \
1118
RUN apt-get -y install --no-install-recommends \
1219
libffi-dev libsqlite3-dev
1320

21+
# Install ASDF
22+
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
23+
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; \
24+
tar -xvzf /tmp/asdf.tar.gz; \
25+
mv asdf /usr/bin
26+
1427
USER vscode
1528

16-
# 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;
2029

2130
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/nhs-eps-spine-client/node_modules/.bins:/home/vscode/.asdf/shims"
2231

@@ -32,9 +41,6 @@ WORKDIR /workspaces/nhs-eps-spine-client
3241
ADD .tool-versions /workspaces/nhs-eps-spine-client/.tool-versions
3342
ADD .tool-versions /home/vscode/.tool-versions
3443

35-
RUN asdf install python && asdf reshim python
36-
RUN asdf install poetry && asdf reshim poetry
3744

38-
RUN asdf install; \
39-
asdf reshim nodejs; \
40-
asdf direnv setup --shell bash --version 2.32.2;
45+
RUN asdf install python; \
46+
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 & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,65 +10,31 @@ jobs:
1010
secrets:
1111
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1212

13-
tag_release:
14-
needs: quality_checks
13+
get_asdf_version:
1514
runs-on: ubuntu-22.04
15+
outputs:
16+
asdf_version: ${{ steps.asdf-version.outputs.version }}
17+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
1618
steps:
1719
- name: Checkout code
1820
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-
3721

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
22+
- name: Get asdf version
23+
id: asdf-version
24+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
25+
- name: Load config value
26+
id: load-config
4627
run: |
47-
make install-node
28+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
29+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
4830
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}" = "undefined" ]
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 }}
31+
tag_release:
32+
needs: [quality_checks, get_asdf_version]
33+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@93f17b9c7eb6f5413c469d1433743631225b2ce2
34+
with:
35+
dry_run: true
36+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
37+
branch_name: main
38+
publish_package: false
39+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
40+
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@93f17b9c7eb6f5413c469d1433743631225b2ce2
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@93f17b9c7eb6f5413c469d1433743631225b2ce2
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-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_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@93f17b9c7eb6f5413c469d1433743631225b2ce2
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)