Skip to content

Commit 9fd26cd

Browse files
authoredFeb 13, 2023
ci(release): github actions to release next branch (#8380)
* swagger-ui * swagger-ui-react
1 parent fb2eefc commit 9fd26cd

File tree

4 files changed

+193
-0
lines changed

4 files changed

+193
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build & Release SwaggerUI-React@next
2+
3+
# single-stage
4+
on:
5+
workflow_dispatch:
6+
branches:
7+
- next
8+
9+
# multi-stage automation
10+
# on:
11+
# workflow_run:
12+
# workflows: ["Release SwaggerUI@next"]
13+
# types:
14+
# - completed
15+
# branches: [next]
16+
17+
defaults:
18+
run:
19+
working-directory: flavors/swagger-ui-react/release
20+
jobs:
21+
release-swagger-ui-react:
22+
name: Release SwaggerUI React
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 0
29+
persist-credentials: false
30+
submodules: true
31+
ref: next
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: 16
37+
registry-url: https://npm.pkg.github.com/
38+
scope: "@swagger-api"
39+
40+
- name: Install dependencies (to create package manifest)
41+
run: npm ci
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
44+
45+
- name: MKDIR `dist` working directory
46+
run: mkdir -p ../dist
47+
48+
- name: Copy SwaggerUI dist files to MKDIR
49+
run: |
50+
ls ../dist
51+
cp ../../../dist/swagger-ui-es-bundle-core.js ../dist
52+
cp ../../../dist/swagger-ui-es-bundle-core.js.map ../dist
53+
cp ../../../dist/swagger-ui.css ../dist
54+
cp ../../../dist/swagger-ui.css.map ../dist
55+
56+
- name: Create a releasable package manifest
57+
run: node create-manifest.js > ../dist/package.json
58+
59+
- name: Transpile our top-level React Component
60+
run: |
61+
../../../node_modules/.bin/cross-env BABEL_ENV=commonjs ../../../node_modules/.bin/babel --config-file ../../../babel.config.js ../index.jsx > ../dist/commonjs.js
62+
../../../node_modules/.bin/cross-env BABEL_ENV=es ../../../node_modules/.bin/babel --config-file ../../../babel.config.js ../index.jsx > ../dist/index.js
63+
64+
- name: Copy our README into the dist folder for npm
65+
run: cp ../README.md ../dist
66+
67+
- name: Copy LICENSE & NOTICE into the dist folder for npm
68+
run: |
69+
cp ../../../LICENSE ../dist
70+
cp ../../../NOTICE ../dist
71+
72+
- name: Run the release from the dist folder
73+
run: |
74+
cd ../dist
75+
pwd
76+
npm pack .
77+
env:
78+
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release SwaggerUI@next
2+
3+
on:
4+
workflow_dispatch:
5+
branches:
6+
- next
7+
8+
jobs:
9+
release-swagger-ui:
10+
name: Release SwaggerUI
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
persist-credentials: false
18+
submodules: true
19+
ref: next
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 16
25+
registry-url: https://npm.pkg.github.com/
26+
scope: "@swagger-api"
27+
28+
- name: Determine the next release version
29+
uses: cycjimmy/semantic-release-action@v3
30+
with:
31+
dry_run: true
32+
extra_plugins: |
33+
@semantic-release/git
34+
@semantic-release/exec
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
37+
NPM_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
38+
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
39+
40+
- name: Nothing to release
41+
if: ${{ env.NEXT_RELEASE_VERSION == '' }}
42+
uses: actions/github-script@v6
43+
with:
44+
script: |
45+
core.setFailed('Nothing to release')
46+
47+
- name: Install dependencies
48+
run: npm ci
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
51+
52+
- name: Semantic Release
53+
id: semantic
54+
uses: cycjimmy/semantic-release-action@v3
55+
with:
56+
dry_run: false
57+
extra_plugins: |
58+
@semantic-release/git
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
61+
NPM_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
62+
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
63+
64+
- name: Release failed
65+
if: steps.semantic.outputs.new_release_published == 'false'
66+
uses: actions/github-script@v6
67+
with:
68+
script: |
69+
core.setFailed('Release failed')
70+
71+
- name: Release published
72+
run: |
73+
echo ${{ steps.semantic.outputs.new_release_version }}
74+
echo ${{ steps.semantic.outputs.new_release_major_version }}
75+
echo ${{ steps.semantic.outputs.new_release_minor_version }}
76+
echo ${{ steps.semantic.outputs.new_release_patch_version }}

‎.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ node_modules
33
.vscode
44
.deps_check
55
.DS_Store
6+
.env.local
7+
.env.development.local
8+
.env.test.local
9+
.env.production.local
610
.nyc_output
711
npm-debug.log*
812
.eslintcache

‎.releaserc

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"branches": [
3+
{
4+
"name": "master"
5+
},
6+
{
7+
"name": "next",
8+
"channel": "alpha",
9+
"prerelease": "alpha"
10+
}
11+
],
12+
"tagFormat": "v${version}",
13+
"plugins": [
14+
"@semantic-release/commit-analyzer",
15+
[
16+
"@semantic-release/exec",
17+
{
18+
"verifyReleaseCmd": "echo \"NEXT_RELEASE_VERSION=${nextRelease.version}\" >> $GITHUB_ENV"
19+
}
20+
],
21+
"@semantic-release/release-notes-generator",
22+
"@semantic-release/npm",
23+
"@semantic-release/github",
24+
[
25+
"@semantic-release/git",
26+
{
27+
"assets": [
28+
"package.json",
29+
"package-lock.json"
30+
],
31+
"message": "chore(release): cut the ${nextRelease.version} release\n\n${nextRelease.notes}"
32+
}
33+
]
34+
]
35+
}

0 commit comments

Comments
 (0)
Please sign in to comment.