Skip to content

Commit 9f146ab

Browse files
floehopperchrisrooschrislo
authored andcommitted
Change CI to publish to GitHub package registry
* Scope the package name by organisation. This ties the package to the RPF organisation rather than just to my user and means that, for example, any member of the organisation can publish the package. * Only publish package on successful builds of the experience-cs branch. * Use organisation-specific release version to avoid confusion with versions in the canonical package and use "experience-cs" string instead of "raspberrypifoundation" to distinguish it from the package version(s) used by the Code Club World project. * Always publish using "latest" npm tag; not "hotfix" or "stable". * 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 the NODE_AUTH_TOKEN, although we need to add the `packages: write` permission to the Action. Co-authored-by: Chris Roos <chris.roos@gofreerange.com> Co-authored-by: Chris Lowis <chris.lowis@gofreerange.com>
1 parent 2848f0e commit 9f146ab

3 files changed

Lines changed: 32534 additions & 32526 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI/CD
33
on:
44
pull_request: # Runs whenever a pull request is created or updated (including from another fork)
55
push: # Runs whenever a commit is pushed to the repository...
6-
branches: [master, develop, hotfix/*] # ...on any of these branches
6+
branches: [experience-cs]
77
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
88
concurrency:
99
group: "${{ github.workflow }} @ ${{ github.head_ref || github.ref }}"
@@ -14,6 +14,7 @@ permissions:
1414
pages: write # deploy to GitHub Pages
1515
issues: write # comment on released issues
1616
pull-requests: write # comment on released pull requests
17+
packages: write # deploy to GitHub Packages
1718

1819
jobs:
1920
ci-cd:
@@ -28,6 +29,7 @@ jobs:
2829
with:
2930
cache: "npm"
3031
node-version-file: ".nvmrc"
32+
registry-url: "https://npm.pkg.github.com"
3133
- name: Info
3234
run: |
3335
cat <<EOF
@@ -79,11 +81,14 @@ jobs:
7981
if [[ ${{contains(github.ref, 'hotfix')}} ]]; then
8082
sed -e "s|hotfix/REPLACE|${{ github.ref_name }}|" --in-place release.config.js
8183
fi
82-
- name: Semantic Release
84+
- name: Publish to GitHub Packages
85+
if: github.ref == 'refs/heads/experience-cs'
86+
run: |
87+
RELEASE_VERSION="0.1.0-experience-cs.$(date +'%Y%m%d%H%M%S')"
88+
npm version --no-git-tag-version $RELEASE_VERSION
89+
npm publish --access public --tag latest
8390
env:
84-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
85-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86-
run: npx --no -- semantic-release
91+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8792
- name: Deploy playground to GitHub Pages
8893
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
8994
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'

0 commit comments

Comments
 (0)