Skip to content

Commit 7f81e5c

Browse files
sebjacobschrislo
andcommitted
ci: change CI to publish to GitHub package registry
* Only publish package on successful builds of the experience-cs branch. * Configure npm to use github registry URL * Use organisation-specific release version to avoid confusion with versions in the canonical package and use "experience-cs" string to distinguish it from the package version(s) used by other projects. * Always publish using "latest" npm tag. * Add `--access public` option to `npm publish` command, because scoped packages only allow "restricted" access by default. * We can use the GITHUB_TOKEN that is made available by default in a GitHub Action as `NODE_AUTH_TOKEN`, although we need to add the `packages: write` permission to the Action. Co-authored-by: Chris Lowis <[email protected]>
1 parent 4610e49 commit 7f81e5c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

.github/workflows/ci-cd.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: CI/CD
33
on:
44
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
55
push: # Runs whenever a commit is pushed to the repository
6+
branches: [experience-cs]
67

78
concurrency:
89
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
@@ -13,6 +14,7 @@ permissions:
1314
pages: write # deploy to GitHub Pages
1415
issues: write # comment on released issues
1516
pull-requests: write # comment on released pull requests
17+
packages: write # deploy to GitHub Packages
1618

1719
jobs:
1820
ci-cd:
@@ -27,6 +29,7 @@ jobs:
2729
with:
2830
cache: "npm"
2931
node-version-file: ".nvmrc"
32+
registry-url: "https://npm.pkg.github.com"
3033

3134
- name: Info
3235
run: |
@@ -45,7 +48,8 @@ jobs:
4548
4649
- name: Semantic release (configured to run dry if branch is other than 'develop')
4750
env:
48-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5052
run: |
51-
npx --no -- semantic-release
53+
RELEASE_VERSION="0.1.0-experience-cs.$(date +'%Y%m%d%H%M%S')"
54+
npm version --no-git-tag-version $RELEASE_VERSION
55+
npm publish --access public --tag latest

0 commit comments

Comments
 (0)