-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
142 lines (132 loc) · 4.6 KB
/
release-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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