1.10.0 #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: New p5.js release | |
# Requires secrets `NPM_TOKEN` and `ACCESS_TOKEN` to be set | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- 'v*.*.*' # Push events to matching v*.*.*, i.e. v20.15.10 | |
- 'v*.*.*-*' # Push events to matching v*.*.*-*, i.e. v20.15.10-0 | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
name: Release | |
env: | |
INPUT_TOKEN: ${{ secrets.NPM_TOKEN }} | |
steps: | |
# 1. Setup | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Get semver info | |
id: semver | |
uses: akshens/semver-tag@v4 | |
with: | |
version: ${{ github.ref_name }} | |
- name: Get version number | |
id: version-number | |
run: | | |
version=$(echo ${{ github.ref_name }} | cut -c 2-) | |
echo "version=$version" >> $GITHUB_OUTPUT | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +"%B %Oe, %Y")" >> $GITHUB_OUTPUT | |
- name: Install dependencies | |
run: npm ci | |
env: | |
CI: true | |
- name: Run build | |
run: npm test | |
env: | |
CI: true | |
- run: rm ./lib/p5-test.js ./lib/p5.pre-min.js | |
# 2. Prepare release files | |
- run: mkdir release && mkdir p5 && cp -r ./lib/* p5/ | |
- name: Create release zip file | |
uses: TheDoctor0/[email protected] | |
with: | |
type: zip | |
filename: release/p5.zip | |
path: ./p5/* | |
- name: Copy release files | |
run: cp lib/p5.js lib/p5.min.js lib/addons/p5.sound.js lib/addons/p5.sound.min.js release/ | |
# 3. Release p5.js | |
- name: Create GitHub release | |
uses: softprops/[email protected] | |
with: | |
draft: true | |
prerelease: ${{ steps.semver.outputs.is-prerelease == 'true' }} | |
files: release/* | |
generate_release_notes: true | |
token: ${{ secrets.ACCESS_TOKEN }} | |
- name: Publish to NPM | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
# 4. Update p5.js website | |
- name: Clone p5.js website | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
uses: actions/checkout@v3 | |
with: | |
repository: processing/p5.js-website | |
path: website | |
fetch-depth: 0 | |
token: ${{ secrets.ACCESS_TOKEN }} | |
- name: Updated website files | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
run: | | |
cd website | |
npm install | |
npm run build:contributor-docs | |
npm run build:contributors | |
npm run build:reference | |
npm run build:search | |
npm run build:p5-version | |
- name: Commit updated website files | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
run: | | |
cd website | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add . | |
git commit -m "Update p5.js to ${{ github.ref_name }}" | |
- name: Push updated website repo | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.ACCESS_TOKEN }} | |
branch: main | |
directory: website/ | |
repository: processing/p5.js-website | |
# 5. Update Bower files | |
- name: Checkout Bower repo | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
uses: actions/checkout@v3 | |
with: | |
repository: processing/p5.js-release | |
path: bower | |
fetch-depth: 0 | |
token: ${{ secrets.ACCESS_TOKEN }} | |
- name: Copy new version files to Bower repo | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
run: | | |
cp lib/*.js bower/lib/ | |
cp lib/addons/* bower/lib/addons/ | |
- name: Commit updated Bower files | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
run: | | |
cd bower | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add . | |
git commit -m "Update p5.js to ${{ github.ref_name }}" | |
- name: Push updated Bower repo | |
if: ${{ steps.semver.outputs.is-prerelease != 'true' }} | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.ACCESS_TOKEN }} | |
branch: master | |
directory: bower/ | |
repository: processing/p5.js-release |