|
8 | 8 | BRANCH_NAME: ${{ github.ref_name }} |
9 | 9 |
|
10 | 10 | jobs: |
11 | | - quality_checks: |
12 | | - uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/quality-checks.yml@v4.1.3 |
13 | | - secrets: |
14 | | - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
15 | | - |
16 | 11 | get_commit_id: |
17 | 12 | runs-on: ubuntu-22.04 |
18 | 13 | outputs: |
19 | 14 | commit_id: ${{ steps.commit_id.outputs.commit_id }} |
| 15 | + sha_short: ${{ steps.commit_id.outputs.sha_short }} |
| 16 | + |
20 | 17 | steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v5 |
| 20 | + with: |
| 21 | + ref: ${{ env.BRANCH_NAME }} |
| 22 | + |
21 | 23 | - name: Get Commit ID |
22 | 24 | id: commit_id |
23 | 25 | run: | |
| 26 | + # echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV" |
24 | 27 | echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT" |
25 | | -
|
26 | | - tag_release: |
27 | | - needs: quality_checks |
| 28 | + echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" |
| 29 | + get_asdf_version: |
28 | 30 | runs-on: ubuntu-22.04 |
29 | 31 | outputs: |
30 | | - version_tag: ${{steps.output_version_tag.outputs.VERSION_TAG}} |
| 32 | + asdf_version: ${{ steps.asdf-version.outputs.version }} |
| 33 | + tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }} |
31 | 34 | steps: |
32 | 35 | - name: Checkout code |
33 | 36 | 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- |
52 | 37 |
|
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 |
59 | | - |
60 | | - - name: Setting up .npmrc |
61 | | - env: |
62 | | - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + - name: Get asdf version |
| 39 | + id: asdf-version |
| 40 | + run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT" |
| 41 | + - name: Load config value |
| 42 | + id: load-config |
63 | 43 | run: | |
64 | | - echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc |
65 | | - echo "@NHSDigital:registry=https://npm.pkg.github.com" >> ~/.npmrc |
66 | | -
|
67 | | - - name: Install node packages |
68 | | - run: | |
69 | | - make install-node |
| 44 | + TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml) |
| 45 | + echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT" |
| 46 | + quality_checks: |
| 47 | + uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/quality-checks.yml@4a6d03ad51516eddc448daf454805f85fe2025b9 |
| 48 | + needs: [get_asdf_version, get_commit_id] |
| 49 | + with: |
| 50 | + asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }} |
| 51 | + secrets: |
| 52 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
70 | 53 |
|
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 }} |
97 | | - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + tag_release: |
| 55 | + needs: [quality_checks, get_commit_id, get_asdf_version] |
| 56 | + uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99 |
| 57 | + with: |
| 58 | + dry_run: false |
| 59 | + asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }} |
| 60 | + branch_name: main |
| 61 | + publish_package: false |
| 62 | + tag_format: ${{ needs.get_asdf_version.outputs.tag_format }} |
| 63 | + secrets: inherit |
98 | 64 |
|
99 | 65 | package_code: |
100 | 66 | needs: [tag_release, quality_checks, get_commit_id] |
@@ -141,3 +107,27 @@ jobs: |
141 | 107 | DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}} |
142 | 108 | secrets: |
143 | 109 | CDK_PUSH_IMAGE_ROLE: ${{ secrets.REF_CDK_PUSH_IMAGE_ROLE }} |
| 110 | + |
| 111 | + release_int: |
| 112 | + needs: [tag_release, release_qa, package_code, get_commit_id] |
| 113 | + uses: ./.github/workflows/docker_image_upload.yml |
| 114 | + with: |
| 115 | + AWS_ENVIRONMENT: int |
| 116 | + VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 117 | + COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }} |
| 118 | + TAG_LATEST: true |
| 119 | + DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}} |
| 120 | + secrets: |
| 121 | + CDK_PUSH_IMAGE_ROLE: ${{ secrets.INT_CDK_PUSH_IMAGE_ROLE }} |
| 122 | + |
| 123 | + release_prod: |
| 124 | + needs: [tag_release, release_int, package_code, get_commit_id] |
| 125 | + uses: ./.github/workflows/docker_image_upload.yml |
| 126 | + with: |
| 127 | + AWS_ENVIRONMENT: prod |
| 128 | + VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 129 | + COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }} |
| 130 | + TAG_LATEST: true |
| 131 | + DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}} |
| 132 | + secrets: |
| 133 | + CDK_PUSH_IMAGE_ROLE: ${{ secrets.PROD_CDK_PUSH_IMAGE_ROLE }} |
0 commit comments