Skip to content

Commit cdd82d7

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 cdd82d7

3 files changed

Lines changed: 32 additions & 12 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
name: CI/CD
22

33
on:
4+
<<<<<<< HEAD
45
pull_request: # Runs whenever a pull request is created or updated (including from another fork)
56
push: # Runs whenever a commit is pushed to the repository...
67
branches: [master, develop, hotfix/*] # ...on any of these branches
78
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
9+
=======
10+
<<<<<<< HEAD
11+
workflow_dispatch:
12+
push:
13+
=======
14+
pull_request: # Runs whenever a pull request is created or updated (including from another fork)
15+
push: # Runs whenever a commit is pushed to the repository...
16+
branches: [experience-cs] # ...on any of these branches
17+
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
18+
>>>>>>> 657fd15d5 (Change CI to publish to GitHub package registry)
19+
>>>>>>> efb1bc407 (Change CI to publish to GitHub package registry)
820
concurrency:
921
group: "${{ github.workflow }} @ ${{ github.head_ref || github.ref }}"
1022
cancel-in-progress: true
@@ -14,6 +26,7 @@ permissions:
1426
pages: write # deploy to GitHub Pages
1527
issues: write # comment on released issues
1628
pull-requests: write # comment on released pull requests
29+
packages: write # deploy to GitHub Packages
1730

1831
jobs:
1932
ci-cd:
@@ -28,6 +41,7 @@ jobs:
2841
with:
2942
cache: "npm"
3043
node-version-file: ".nvmrc"
44+
registry-url: "https://npm.pkg.github.com"
3145
- name: Info
3246
run: |
3347
cat <<EOF
@@ -79,11 +93,14 @@ jobs:
7993
if [[ ${{contains(github.ref, 'hotfix')}} ]]; then
8094
sed -e "s|hotfix/REPLACE|${{ github.ref_name }}|" --in-place release.config.js
8195
fi
82-
- name: Semantic Release
96+
- name: Publish to GitHub Packages
97+
if: github.ref == 'refs/heads/experience-cs'
98+
run: |
99+
RELEASE_VERSION="0.1.0-experience-cs.$(date +'%Y%m%d%H%M%S')"
100+
npm version --no-git-tag-version $RELEASE_VERSION
101+
npm publish --access public --tag latest
83102
env:
84-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
85-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86-
run: npx --no -- semantic-release
103+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87104
- name: Deploy playground to GitHub Pages
88105
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
89106
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'

package-lock.json

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

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
2-
"name": "scratch-gui",
3-
"version": "4.1.7",
2+
"name": "@RaspberryPiFoundation/scratch-gui",
3+
"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)