|
| 1 | +name: New p5.js release |
| 2 | +# Requires secrets `NPM_TOKEN` and `ACCESS_TOKEN` to be set |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + name: Release |
| 13 | + steps: |
| 14 | + # 1. Setup |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + - uses: actions/setup-node@v3 |
| 17 | + with: |
| 18 | + node-version: 14 |
| 19 | + - name: Get version number |
| 20 | + id: version-number |
| 21 | + run: | |
| 22 | + version=$(echo ${{ github.ref_name }} | cut -c 2-) |
| 23 | + echo "::set-output name=version::$version" |
| 24 | + - name: Install dependencies |
| 25 | + run: npm ci |
| 26 | + env: |
| 27 | + CI: true |
| 28 | + - name: Run build |
| 29 | + run: npm test |
| 30 | + env: |
| 31 | + CI: true |
| 32 | + - run: rm ./lib/p5-test.js ./lib/p5.pre-min.js |
| 33 | + |
| 34 | + # 2. Prepare release files |
| 35 | + - run: mkdir release |
| 36 | + - name: Create release zip file |
| 37 | + uses: TheDoctor0/[email protected] |
| 38 | + with: |
| 39 | + type: zip |
| 40 | + filename: release/p5.zip |
| 41 | + path: ./lib |
| 42 | + - name: Copy release files |
| 43 | + run: cp lib/p5.js lib/p5.min.js lib/addons/p5.sound.js lib/addons/p5.sound.min.js release/ |
| 44 | + |
| 45 | + # 3. Release p5.js |
| 46 | + - name: Create GitHub release |
| 47 | + |
| 48 | + with: |
| 49 | + files: release/* |
| 50 | + generate_release_notes: true |
| 51 | + - name: Publish to NPM |
| 52 | + uses: JS-DevTools/npm-publish@v1 |
| 53 | + with: |
| 54 | + token: ${{ secrets.NPM_TOKEN }} |
| 55 | + |
| 56 | + # 4. Update website files |
| 57 | + - name: Checkout website repo |
| 58 | + uses: actions/checkout@v3 |
| 59 | + with: |
| 60 | + repository: processing/p5.js-website |
| 61 | + path: website |
| 62 | + fetch-depth: 0 |
| 63 | + token: ${{ secrets.ACCESS_TOKEN }} |
| 64 | + - name: Copy reference files to website repo |
| 65 | + run: cp docs/reference/data.* website/src/templates/pages/reference/ |
| 66 | + - name: Copy library files to website repo |
| 67 | + run: cp lib/p5.min.js lib/addons/p5.sound.min.js website/src/assets/js/ |
| 68 | + - name: Modify version number on website |
| 69 | + |
| 70 | + with: |
| 71 | + valueFile: website/src/data/data.yml |
| 72 | + propertyPath: version |
| 73 | + value: ${{ steps.version-number.outputs.version }} |
| 74 | + commitChange: false |
| 75 | + updateFile: true |
| 76 | + - name: Update en.json on website repo |
| 77 | + run: | |
| 78 | + cd website |
| 79 | + npm ci |
| 80 | + npx grunt generate_enJSON |
| 81 | + - name: Commit updated website files |
| 82 | + run: | |
| 83 | + cd website |
| 84 | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 85 | + git config --local user.name "github-actions[bot]" |
| 86 | + git add . |
| 87 | + git commit -m "Update p5.js to ${{ github.ref_name }}" |
| 88 | + - name: Push updated website repo |
| 89 | + |
| 90 | + with: |
| 91 | + github_token: ${{ secrets.ACCESS_TOKEN }} |
| 92 | + branch: main |
| 93 | + directory: website/ |
| 94 | + repository: processing/p5.js-website |
| 95 | + |
| 96 | + # 5. Update Bower files |
| 97 | + - name: Checkout Bower repo |
| 98 | + uses: actions/checkout@v3 |
| 99 | + with: |
| 100 | + repository: processing/p5.js-release |
| 101 | + path: bower |
| 102 | + fetch-depth: 0 |
| 103 | + token: ${{ secrets.ACCESS_TOKEN }} |
| 104 | + - name: Copy new version files to Bower repo |
| 105 | + run: | |
| 106 | + cp lib/*.js bower/lib/ |
| 107 | + cp lib/addons/* bower/lib/addons/ |
| 108 | + - name: Commit updated Bower files |
| 109 | + run: | |
| 110 | + cd bower |
| 111 | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 112 | + git config --local user.name "github-actions[bot]" |
| 113 | + git add . |
| 114 | + git commit -m "Update p5.js to ${{ github.ref_name }}" |
| 115 | + - name: Push updated Bower repo |
| 116 | + |
| 117 | + with: |
| 118 | + github_token: ${{ secrets.ACCESS_TOKEN }} |
| 119 | + branch: master |
| 120 | + directory: bower/ |
| 121 | + repository: processing/p5.js-release |
0 commit comments