File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515permissions :
1616 id-token : write
1717 contents : write
18- packages : read
18+ packages : write
1919
2020jobs :
2121 metadata :
Original file line number Diff line number Diff line change @@ -163,6 +163,12 @@ jobs:
163163 - name : " Run contract test suite"
164164 run : |
165165 make test-contract
166+ - name : " Upload generated contracts"
167+ uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
168+ with :
169+ name : pact-contracts
170+ path : " tests/pact-tests/.pacts"
171+ include-hidden-files : true
166172
167173 test-lint :
168174 name : " Linting"
Original file line number Diff line number Diff line change @@ -40,21 +40,35 @@ jobs:
4040 name : " Publish packages"
4141 runs-on : ubuntu-latest
4242 timeout-minutes : 10
43+ permissions :
44+ contents : read
45+ packages : write
4346
4447 steps :
4548 - name : " Checkout code"
4649 uses : actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
50+ - uses : ./.github/actions/node-install
51+ with :
52+ node-version : ${{ inputs.nodejs_version }}
53+ GITHUB_TOKEN : ${{ github.token }}
4754 - name : " Get artifacts: jekyll docs"
4855 uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
4956 with :
5057 path : ./artifacts/jekyll-docs-${{ inputs.version }}
5158 name : jekyll-docs-${{ inputs.version }}
52-
5359 - name : " Get artifacts: schema"
5460 uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
5561 with :
5662 path : ./artifacts/schemas-${{ inputs.version }}
5763 name : schemas-${{ inputs.version }}
64+ - name : " Get artifacts: pact contracts"
65+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
66+ with :
67+ path : ./pact-contracts/pacts
68+ name : pact-contracts
69+ - name : " Publish pact contracts package"
70+ run : |
71+ scripts/publish-pact-contracts.sh
5872
5973
6074 - name : Draft Release
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ coverage.xml
5757coverage /
5858coverage- * /
5959** /.pacts
60+ /pact-contracts /pacts
6061** /playwright-report
6162** /test-results
6263plugin-cache
Original file line number Diff line number Diff line change 1+ {
2+ "description" : " NHS Notify Digital Letters Pact contracts" ,
3+ "exports" : {
4+ "./pacts/*.json" : {
5+ "default" : " ./pacts/*.json"
6+ }
7+ },
8+ "files" : [
9+ " pacts"
10+ ],
11+ "license" : " MIT" ,
12+ "name" : " @nhsdigital/notify-digital-letters-consumer-contracts" ,
13+ "private" : false ,
14+ "publishConfig" : {
15+ "access" : " public" ,
16+ "registry" : " https://npm.pkg.github.com"
17+ },
18+ "scripts" : {
19+ "lint" : " echo Linting not required" ,
20+ "lint:fix" : " echo Linting not required" ,
21+ "test:unit" : " echo Unit tests not required" ,
22+ "test:unit:coverage" : " echo Unit tests not required" ,
23+ "typecheck" : " echo Typecheck not required"
24+ },
25+ "version" : " 0.0.1"
26+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ published_version=$( npm view @nhsdigital/notify-digital-letters-consumer-contracts --json 2> /dev/null | jq -r ' .["dist-tags"].latest' )
4+
5+ set -euo pipefail
6+
7+ # Fail if there are uncommitted changes as this indicates unexpected changes to the contracts
8+ git diff --quiet tests/pact-tests
9+
10+ local_version=$( cat pact-contracts/package.json | jq -r ' .version' )
11+
12+ branch=$( git branch --show-current)
13+
14+ if [[ ! $branch == " main" ]]; then
15+ echo " Not publishing package because this is not the main branch"
16+ exit 0
17+ fi
18+
19+ if [[ $local_version == $published_version ]]; then
20+ echo " Local version is the same as the latest published version - skipping publish"
21+ exit 0
22+ fi
23+
24+ echo " Local version is different to the latest published version - publishing new version"
25+ npm publish ./pact-contracts
You can’t perform that action at this time.
0 commit comments