|
1 | | -name: Release workflow |
| 1 | +name: merge to main workflow |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: |
5 | | - schedule: |
6 | | - - cron: "0 8 * * 3" |
| 4 | + push: |
| 5 | + branches: [main] |
7 | 6 |
|
8 | 7 | env: |
9 | 8 | BRANCH_NAME: ${{ github.ref_name }} |
10 | 9 |
|
11 | 10 | jobs: |
12 | | - quality_checks: |
13 | | - uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected] |
14 | | - secrets: |
15 | | - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
16 | | - |
17 | 11 | get_commit_id: |
18 | 12 | runs-on: ubuntu-22.04 |
19 | 13 | outputs: |
20 | 14 | commit_id: ${{ steps.commit_id.outputs.commit_id }} |
| 15 | + sha_short: ${{ steps.commit_id.outputs.sha_short }} |
| 16 | + |
21 | 17 | steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v5 |
| 20 | + with: |
| 21 | + ref: ${{ env.BRANCH_NAME }} |
| 22 | + |
22 | 23 | - name: Get Commit ID |
23 | 24 | id: commit_id |
24 | 25 | run: | |
| 26 | + # echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV" |
25 | 27 | echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT" |
26 | | -
|
27 | | - tag_release: |
28 | | - needs: quality_checks |
| 28 | + echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" |
| 29 | + get_asdf_version: |
29 | 30 | runs-on: ubuntu-22.04 |
30 | 31 | outputs: |
31 | | - 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 }} |
32 | 34 | steps: |
33 | 35 | - name: Checkout code |
34 | 36 | 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.14.1 |
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- |
53 | | -
|
54 | | - - name: Install asdf dependencies in .tool-versions |
55 | | - uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302 |
56 | | - with: |
57 | | - asdf_branch: v0.14.1 |
58 | | - env: |
59 | | - PYTHON_CONFIGURE_OPTS: --enable-shared |
60 | | - |
61 | | - - name: Setting up .npmrc |
62 | | - env: |
63 | | - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
64 | | - run: | |
65 | | - echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc |
66 | | - echo "@NHSDigital:registry=https://npm.pkg.github.com" >> ~/.npmrc |
67 | | -
|
68 | | - - name: Install node packages |
69 | | - run: | |
70 | | - make install-node |
71 | 37 |
|
72 | | - - name: Package library |
| 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 |
73 | 43 | run: | |
74 | | - make package |
75 | | -
|
76 | | - - name: Set VERSION_TAG env var to be short git SHA and get next tag version |
77 | | - id: output_version_tag |
78 | | - run: | |
79 | | - VERSION_TAG=$(git rev-parse --short HEAD) |
80 | | - npx semantic-release --dry-run > semantic-release-output.log |
81 | | - NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/') |
82 | | - if [ -z "${NEXT_VERSION}" ] |
83 | | - then |
84 | | - echo "Could not get next tag. Here is the log from semantic-release" |
85 | | - cat semantic-release-output.log |
86 | | - exit 1 |
87 | | - fi |
88 | | - tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)") |
89 | | - if [ "${tagFormat}" = "null" ] |
90 | | - then |
91 | | - tagFormat="v\${version}" |
92 | | - fi |
93 | | - # disabling shellcheck as replace does not work |
94 | | - # shellcheck disable=SC2001 |
95 | | - VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/") |
96 | | - echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY" |
97 | | - echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT" |
98 | | - echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV" |
99 | | - env: |
100 | | - GITHUB_TOKEN: ${{ github.token }} |
101 | | - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
102 | | - |
103 | | - - name: tag release |
104 | | - env: |
105 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
106 | | - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
107 | | - run: | |
108 | | - npx semantic-release |
109 | | -
|
110 | | - - name: Get release for editing |
111 | | - id: get_release |
112 | | - # version 1.2.4 |
113 | | - uses: cardinalby/git-get-release-action@5172c3a026600b1d459b117738c605fabc9e4e44 |
114 | | - env: |
115 | | - GITHUB_TOKEN: ${{ github.token }} |
116 | | - with: |
117 | | - tag: ${{ env.VERSION_TAG }} |
| 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 }} |
118 | 53 |
|
119 | | - - name: Edit Release |
120 | | - # version 1.2.0 |
121 | | - uses: irongut/EditRelease@ccf529ad26dddf9996e7dd0f24ca5da4ea507cc2 |
122 | | - with: |
123 | | - token: ${{ secrets.GITHUB_TOKEN }} |
124 | | - id: ${{ steps.get_release.outputs.id }} |
125 | | - body: | |
126 | | - ## Info |
127 | | - [See code diff](${{ github.event.compare }}) |
128 | | - [Release workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
129 | | - It was initialized by [${{ github.event.sender.login }}](${{ github.event.sender.html_url }}) |
| 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: true |
| 62 | + tag_format: ${{ needs.get_asdf_version.outputs.tag_format }} |
| 63 | + secrets: inherit |
130 | 64 |
|
131 | 65 | package_code: |
132 | 66 | needs: [tag_release, quality_checks, get_commit_id] |
133 | 67 | uses: ./.github/workflows/docker_image_build.yml |
134 | 68 | with: |
135 | 69 | VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
136 | 70 | COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }} |
137 | | - |
138 | 71 | package_npm_code: |
139 | 72 | needs: [tag_release, quality_checks, get_commit_id] |
140 | 73 | uses: ./.github/workflows/package_npm_code.yml |
|
0 commit comments