Skip to content

Commit 657fd15

Browse files
floehopperchrisrooschrislo
committed
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 <[email protected]> Co-authored-by: Chris Lowis <[email protected]>
1 parent 44b71a8 commit 657fd15

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

.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, alpha, beta, hotfix/*] # ...on any of these branches
6+
branches: [experience-cs] # ...on any of these branches
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'

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
2-
"name": "scratch-gui",
2+
"name": "@RaspberryPiFoundation/scratch-gui",
33
"version": "4.1.0-beta.1",
44
"description": "Graphical User Interface for creating and running Scratch 3.0 projects",
55
"author": "Massachusetts Institute of Technology",
66
"license": "BSD-3-Clause",
7-
"homepage": "https://github.com/scratchfoundation/scratch-gui#readme",
7+
"homepage": "https://github.com/RaspberryPiFoundation/scratch-gui#readme",
88
"repository": {
99
"type": "git",
10-
"url": "https://github.com/scratchfoundation/scratch-gui.git"
10+
"url": "https://github.com/RaspberryPiFoundation/scratch-gui.git"
11+
},
12+
"publishConfig": {
13+
"registry": "https://npm.pkg.github.com"
1114
},
1215
"main": "./dist/scratch-gui.js",
1316
"scripts": {

0 commit comments

Comments
 (0)