ci: use semantic-release

This commit is contained in:
Christopher Willis-Ford 2023-12-20 18:22:33 -08:00
parent bbafc30c17
commit dca744624c
4 changed files with 10215 additions and 44 deletions

View file

@ -3,9 +3,7 @@ name: CI/CD
on:
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
pull_request: # Runs whenever a pull request is created or updated
push: # Runs whenever a commit is pushed to the repository
branches: [master, develop, hotfix/*]
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
@ -40,42 +38,14 @@ jobs:
GitHub head ref: ${{ github.head_ref }}
EOF
- name: Setup & Test
run: |
npm ci
npm run test
- run: npm ci
- name: Generate release version
run: |
export NODE_ENV=production
export RELEASE_TIMESTAMP=$(date +'%Y%m%d%H%M%S')
export VPKG=$($(npm bin)/json -f package.json version)
export VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP}
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
if [[ "${GITHUB_REF##*/}" == hotfix/* ]]; then
echo "NPM_TAG=hotfix" >> $GITHUB_ENV
else
echo "NPM_TAG=latest" >> $GITHUB_ENV
fi
- run: npm test
- name: Build
run: |
npm run build
npm --no-git-tag-version version $RELEASE_VERSION
- run: npm run build
- name: Deploy to NPM (do a dry-run if not on master, develop, or hotfix/*)
- name: Run semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TAG: ${{ env.NPM_TAG }}
run: |
message=$([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "DRY RUN of" || echo "Deploying")
echo "$message version $RELEASE_VERSION to $NPM_TAG"
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
npm publish --tag $NPM_TAG $([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "--dry-run")
- name: Check Release Version and Create Tag
run: |
if npm info | grep -q $RELEASE_VERSION; then
git tag $RELEASE_VERSION
git push origin $RELEASE_VERSION
fi
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx --no -- semantic-release

10195
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "scratch-audio",
"version": "0.1.0",
"version": "0.0.0",
"description": "audio engine for scratch 3.0",
"main": "dist.js",
"browser": "./src/index.js",
@ -14,14 +14,14 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/LLK/scratch-audio.git"
"url": "git+https://github.com/scratchfoundation/scratch-audio.git"
},
"author": "Massachusetts Institute of Technology",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/LLK/scratch-audio/issues"
},
"homepage": "https://github.com/LLK/scratch-audio#readme",
"homepage": "https://github.com/scratchfoundation/scratch-audio#readme",
"dependencies": {
"audio-context": "1.0.1",
"minilog": "^3.0.1",
@ -38,6 +38,8 @@
"eslint-config-scratch": "9.0.3",
"husky": "8.0.3",
"json": "9.0.6",
"scratch-semantic-release-config": "1.0.8",
"semantic-release": "19.0.5",
"tap": "12.7.0",
"web-audio-test-api": "0.5.2",
"webpack": "4.46.0",

14
release.config.js Normal file
View file

@ -0,0 +1,14 @@
module.exports = {
extends: 'scratch-semantic-release-config',
branches: [
{
name: 'develop'
// default channel
},
{
name: 'hotfix/*',
channel: 'hotfix',
prerelease: 'hotfix'
}
]
};