Skip to content

Commit 51bbd62

Browse files
authored
Automated release setup (#170)
1 parent ef46650 commit 51bbd62

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## What does this PR do?
2+
3+
[Description here]
4+
5+
## Checklist
6+
7+
- [ ] All new functionality has tests.
8+
- [ ] All tests are passing.
9+
- [ ] New or changed API methods have been documented.
10+
- [ ] `npm run format` has been run
11+
12+
## CHANGELOG
13+
14+
- [CHANGED] Describe your change here. Look at CHANGELOG.md to see the format.

.github/workflows/release.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
on:
2+
push:
3+
branches: [master]
4+
5+
jobs:
6+
check-release-tag:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v2
11+
with:
12+
fetch-depth: 0
13+
- name: Prepare tag
14+
id: prepare_tag
15+
continue-on-error: true
16+
run: |
17+
export TAG=v$(jq -r '.version' package.json)
18+
echo "TAG=$TAG" >> $GITHUB_ENV
19+
20+
export CHECK_TAG=$(git tag | grep $TAG)
21+
if [[ $CHECK_TAG ]]; then
22+
echo "Skipping because release tag already exists"
23+
exit 1
24+
fi
25+
- name: Output
26+
id: release_output
27+
if: ${{ steps.prepare_tag.outcome == 'success' }}
28+
run: |
29+
echo "::set-output name=tag::${{ env.TAG }}"
30+
outputs:
31+
tag: ${{ steps.release_output.outputs.tag }}
32+
33+
create-github-release:
34+
runs-on: ubuntu-latest
35+
needs: check-release-tag
36+
if: ${{ needs.check-release-tag.outputs.tag }}
37+
steps:
38+
- uses: actions/checkout@v2
39+
- name: Prepare tag
40+
run: |
41+
export TAG=v$(jq -r '.version' package.json)
42+
echo "TAG=$TAG" >> $GITHUB_ENV
43+
- name: Setup git
44+
run: |
45+
git config user.email "pusher-ci@pusher.com"
46+
git config user.name "Pusher CI"
47+
- name: Prepare description
48+
run: |
49+
csplit -s CHANGELOG.md "/##/" {1}
50+
cat xx01 > CHANGELOG.tmp
51+
- name: Create Release
52+
uses: actions/create-release@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
tag_name: ${{ env.TAG }}
57+
release_name: ${{ env.TAG }}
58+
body_path: CHANGELOG.tmp
59+
draft: false
60+
prerelease: false
61+
62+
publish-to-npm:
63+
runs-on: ubuntu-latest
64+
needs: create-github-release
65+
steps:
66+
- uses: actions/checkout@v2
67+
- uses: flood-io/is-published-on-npm@8478347e2650eb228d303975415458183d0a37e4
68+
id: is-published
69+
- run: echo "This version is already published on NPM"
70+
if: ${{ steps.is-published.outputs.published == 'true' }}
71+
- uses: actions/setup-node@v2
72+
if: ${{ steps.is-published.outputs.published == 'false' }}
73+
with:
74+
node-version: "14"
75+
registry-url: https://registry.npmjs.org/
76+
- run: npm install
77+
if: ${{ steps.is-published.outputs.published == 'false' }}
78+
- run: npm publish --access public
79+
if: ${{ steps.is-published.outputs.published == 'false' }}
80+
env:
81+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
82+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release_pr.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: release
2+
3+
on:
4+
pull_request:
5+
types: [labeled]
6+
branches:
7+
- master
8+
9+
jobs:
10+
prepare-release:
11+
name: Prepare release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Get current version
16+
shell: bash
17+
run: |
18+
CURRENT_VERSION=$(jq -r '.version' package.json)
19+
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
20+
- uses: actions/checkout@v2
21+
with:
22+
repository: pusher/actions
23+
token: ${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
24+
path: .github/actions
25+
- uses: ./.github/actions/prepare-version-bump
26+
id: bump
27+
with:
28+
current_version: ${{ env.CURRENT_VERSION }}
29+
- uses: actions/setup-node@v2
30+
with:
31+
node-version: "14"
32+
- run: npm install
33+
- name: Push
34+
shell: bash
35+
run: |
36+
echo "$(jq '.version = "${{ steps.bump.outputs.new_version }}"' package.json)" > package.json
37+
38+
make build_all
39+
40+
git add package.json CHANGELOG.md dist/
41+
git commit -m "Bump to version ${{ steps.bump.outputs.new_version }}"
42+
git push

0 commit comments

Comments
 (0)