Skip to content

Commit 1c5f050

Browse files
committed
move to common workflow
1 parent 41d3fc0 commit 1c5f050

File tree

10 files changed

+119
-6483
lines changed

10 files changed

+119
-6483
lines changed

.devcontainer/Dockerfile

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
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+
9+
# Add amd64 architecture if on arm64
10+
RUN if [ "$TARGETARCH" == "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then dpkg --add-architecture amd64; fi
11+
312
RUN apt-get update \
413
&& export DEBIAN_FRONTEND=noninteractive \
514
&& apt-get -y dist-upgrade \
@@ -12,32 +21,42 @@ RUN apt-get update \
1221
xz-utils tk-dev liblzma-dev netcat-traditional ruby-full build-essential zlib1g-dev \
1322
&& apt remove -y openjdk-8-jdk-headless openjdk-8-jre-headless openjdk-8-jre
1423

15-
# install aws stuff
16-
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
24+
# Download correct AWS CLI for arch
25+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
26+
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
27+
else \
28+
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \
29+
fi && \
1730
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \
1831
/tmp/aws-cli/aws/install && \
19-
rm tmp/awscliv2.zip && \
20-
rm -rf /tmp/aws-cli
21-
22-
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 && \
32+
rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli
33+
34+
# Download correct SAM CLI for arch
35+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
36+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip"; \
37+
else \
38+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"; \
39+
fi && \
2340
unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \
2441
/tmp/aws-sam-cli/install && \
25-
rm /tmp/aws-sam-cli.zip && \
26-
rm -rf /tmp/aws-sam-cli
27-
28-
USER vscode
42+
rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli
2943

3044
# Install ASDF
31-
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
32-
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
33-
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; \
45+
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
46+
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; \
47+
tar -xvzf /tmp/asdf.tar.gz; \
48+
mv asdf /usr/bin
49+
50+
USER vscode
51+
52+
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
53+
RUN \
54+
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
55+
echo '. <(asdf completion bash)' >> ~/.bashrc; \
3456
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
3557
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
3658
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
3759

38-
ENV PATH="$PATH:/home/vscode/.asdf/bin/"
39-
40-
4160
# Install ASDF plugins
4261
RUN asdf plugin add python; \
4362
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \
@@ -52,7 +71,5 @@ WORKDIR /workspaces/validation-service-fhir-r4
5271
ADD .tool-versions /workspaces/validation-service-fhir-r4/.tool-versions
5372
ADD .tool-versions /home/vscode/.tool-versions
5473

55-
RUN asdf install; \
56-
asdf reshim python; \
57-
asdf reshim poetry; \
58-
asdf reshim java;
74+
RUN asdf install python; \
75+
asdf intstall

.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: 20 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -24,71 +24,34 @@ jobs:
2424
id: commit_id
2525
run: |
2626
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
27-
28-
tag_release:
29-
needs: quality_checks
27+
get_asdf_version:
3028
runs-on: ubuntu-22.04
3129
outputs:
32-
version_tag: ${{steps.output_version_tag.outputs.VERSION_TAG}}
30+
asdf_version: ${{ steps.asdf-version.outputs.version }}
31+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
3332
steps:
3433
- name: Checkout code
3534
uses: actions/checkout@v5
36-
with:
37-
ref: ${{ env.BRANCH_NAME }}
38-
fetch-depth: 0
39-
40-
# using git commit sha for version of action to ensure we have stable version
41-
- name: Install asdf
42-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
43-
with:
44-
asdf_branch: v0.11.3
45-
46-
- name: Cache asdf
47-
uses: actions/cache@v4
48-
with:
49-
path: |
50-
~/.asdf
51-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
52-
restore-keys: |
53-
${{ runner.os }}-asdf-
5435

55-
- name: Install asdf dependencies in .tool-versions
56-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
57-
with:
58-
asdf_branch: v0.11.3
59-
env:
60-
PYTHON_CONFIGURE_OPTS: --enable-shared
61-
62-
- name: Install node packages
36+
- name: Get asdf version
37+
id: asdf-version
38+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
39+
- name: Load config value
40+
id: load-config
6341
run: |
64-
make install-node
42+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
43+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
6544
66-
- name: Set VERSION_TAG env var to be short git SHA and get next tag varsion
67-
id: output_version_tag
68-
run: |
69-
VERSION_TAG=$(git rev-parse --short HEAD)
70-
npx semantic-release --dry-run > semantic-release-output.log
71-
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
72-
if [ -z "${NEXT_VERSION}" ]
73-
then
74-
echo "Could not get next tag. Here is the log from semantic-release"
75-
cat semantic-release-output.log
76-
exit 1
77-
fi
78-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
79-
if [ "${tagFormat}" = "null" ]
80-
then
81-
tagFormat="v\${version}"
82-
fi
83-
# disabling shellcheck as replace does not work
84-
# shellcheck disable=SC2001
85-
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
86-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
87-
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
88-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
89-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
90-
env:
91-
GITHUB_TOKEN: ${{ github.token }}
45+
tag_release:
46+
needs: [quality_checks, get_commit_id, get_asdf_version]
47+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2a3f4ab96e04b7547c4ee5b786745b98809c89be
48+
with:
49+
dry_run: true
50+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
51+
branch_name: main
52+
publish_package: false
53+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
54+
secrets: inherit
9255

9356
package_code:
9457
needs: tag_release

.github/workflows/pr_title_check.yml

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

.github/workflows/pull_request.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
install_java: true
1717

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

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

4876
get_commit_id:
4977
runs-on: ubuntu-22.04

.github/workflows/release.yml

Lines changed: 20 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -24,90 +24,34 @@ jobs:
2424
run: |
2525
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
2626
27-
tag_release:
28-
needs: quality_checks
27+
get_asdf_version:
2928
runs-on: ubuntu-22.04
3029
outputs:
31-
version_tag: ${{steps.output_version_tag.outputs.VERSION_TAG}}
30+
asdf_version: ${{ steps.asdf-version.outputs.version }}
31+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
3232
steps:
3333
- name: Checkout code
3434
uses: actions/checkout@v5
35-
with:
36-
ref: ${{ env.BRANCH_NAME }}
37-
fetch-depth: 0
38-
39-
# using git commit sha for version of action to ensure we have stable version
40-
- name: Install asdf
41-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
42-
with:
43-
asdf_branch: v0.11.3
44-
45-
- name: Cache asdf
46-
uses: actions/cache@v4
47-
with:
48-
path: |
49-
~/.asdf
50-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
51-
restore-keys: |
52-
${{ runner.os }}-asdf-
5335

54-
- name: Install asdf dependencies in .tool-versions
55-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
56-
with:
57-
asdf_branch: v0.11.3
58-
env:
59-
PYTHON_CONFIGURE_OPTS: --enable-shared
60-
61-
- name: Install node packages
62-
run: |
63-
make install-node
64-
65-
- name: Set VERSION_TAG to be next tag varsion
66-
id: output_version_tag
67-
run: |
68-
NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
69-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
70-
if [ "${tagFormat}" = "null" ]
71-
then
72-
tagFormat="v\${version}"
73-
fi
74-
# disabling shellcheck as replace does not work
75-
# shellcheck disable=SC2001
76-
VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
77-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
78-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
79-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
80-
env:
81-
GITHUB_TOKEN: ${{ github.token }}
82-
83-
- name: tag release
84-
env:
85-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Get asdf version
37+
id: asdf-version
38+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
39+
- name: Load config value
40+
id: load-config
8641
run: |
87-
npx semantic-release
88-
89-
- name: Get release for editing
90-
id: get_release
91-
# version 1.2.4
92-
uses: cardinalby/git-get-release-action@5172c3a026600b1d459b117738c605fabc9e4e44
93-
env:
94-
GITHUB_TOKEN: ${{ github.token }}
95-
with:
96-
tag: ${{ env.VERSION_TAG }}
97-
98-
- name: Edit Release
99-
# version 1.2.0
100-
uses: irongut/EditRelease@ccf529ad26dddf9996e7dd0f24ca5da4ea507cc2
101-
with:
102-
token: ${{ secrets.GITHUB_TOKEN }}
103-
id: ${{ steps.get_release.outputs.id }}
104-
body: |
105-
## Info
106-
[See code diff](${{ github.event.compare }})
107-
[Release workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
42+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
43+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
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: false
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
10854

109-
It was initialized by [${{ github.event.sender.login }}](${{ github.event.sender.html_url }})
110-
11155
package_code:
11256
needs: tag_release
11357
uses: ./.github/workflows/sam_package_code.yml

0 commit comments

Comments
 (0)