Skip to content

Commit 371896a

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 371896a

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

.github/workflows/ci-cd.yml

Lines changed: 8 additions & 4 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: |
@@ -43,9 +46,10 @@ jobs:
4346
npm run build
4447
npm run test
4548
46-
- name: Semantic release (configured to run dry if branch is other than 'develop')
49+
- name: Publish to GitHub Packages
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

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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
2-
"name": "scratch-storage",
2+
"name": "@raspberrypifoundation/scratch-storage",
33
"version": "4.0.177",
44
"description": "Load and store project and asset files for Scratch 3.0",
55
"license": "AGPL-3.0-only",
6-
"homepage": "https://github.com/scratchfoundation/scratch-storage#readme",
6+
"homepage": "https://github.com/RaspberryPiFoundation/scratch-storage#readme",
77
"repository": {
88
"type": "git",
9-
"url": "https://github.com/scratchfoundation/scratch-storage.git",
10-
"sha": "672b90817c10d45dd00c7b8d37e8caacae75c9e4"
9+
"url": "https://github.com/RaspberryPiFoundation/scratch-storage.git"
10+
},
11+
"publishConfig": {
12+
"registry": "https://npm.pkg.github.com"
1113
},
1214
"main": "./dist/node/scratch-storage.js",
1315
"browser": "./dist/web/scratch-storage.js",

0 commit comments

Comments
 (0)