Skip to content

Commit a907676

Browse files
committed
set up for publishing
1 parent 8f59e48 commit a907676

File tree

3 files changed

+41
-239
lines changed

3 files changed

+41
-239
lines changed

.github/workflows/ci.yml

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

.github/workflows/release.yml

Lines changed: 39 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,73 @@
1-
name: Release workflow
1+
name: merge to main workflow
22

33
on:
4-
workflow_dispatch:
5-
schedule:
6-
- cron: "0 8 * * 3"
4+
push:
5+
branches: [main]
76

87
env:
98
BRANCH_NAME: ${{ github.ref_name }}
109

1110
jobs:
12-
quality_checks:
13-
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected]
14-
secrets:
15-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
16-
1711
get_commit_id:
1812
runs-on: ubuntu-22.04
1913
outputs:
2014
commit_id: ${{ steps.commit_id.outputs.commit_id }}
15+
sha_short: ${{ steps.commit_id.outputs.sha_short }}
16+
2117
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v5
20+
with:
21+
ref: ${{ env.BRANCH_NAME }}
22+
2223
- name: Get Commit ID
2324
id: commit_id
2425
run: |
26+
# echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV"
2527
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:
2930
runs-on: ubuntu-22.04
3031
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 }}
3234
steps:
3335
- name: Checkout code
3436
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
7137

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
7343
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 }}
11853

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
13064

13165
package_code:
13266
needs: [tag_release, quality_checks, get_commit_id]
13367
uses: ./.github/workflows/docker_image_build.yml
13468
with:
13569
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
13670
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
137-
13871
package_npm_code:
13972
needs: [tag_release, quality_checks, get_commit_id]
14073
uses: ./.github/workflows/package_npm_code.yml

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
2+
@NHSDigital:registry=https://npm.pkg.github.com

0 commit comments

Comments
 (0)