Skip to content

Commit d3e9142

Browse files
authored
ci: add release automation (#7656)
1 parent 626fad2 commit d3e9142

13 files changed

+2227
-2006
lines changed

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: ci
22
on:
33
push:
4-
branches:
5-
- master
4+
branches: [ release, alpha, beta, next-major ]
65
pull_request:
76
branches:
87
- '**'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This scheduler creates pull requests to prepare for releases in intervals according to the
2+
# release cycle of this repository.
3+
4+
name: release-automated-scheduler
5+
on:
6+
# Scheduler temporarily disabled until stable release of Parse Server 5 with all branches (alpha, beta, release) created
7+
# schedule:
8+
# - cron: 0 0 1 * *
9+
workflow_dispatch:
10+
11+
jobs:
12+
create-pr-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout beta branch
16+
uses: actions/checkout@v2
17+
with:
18+
ref: beta
19+
- name: Compose branch name for PR
20+
id: branch
21+
run: echo "::set-output name=name::build-release-${{ github.run_id }}${{ github.run_number }}"
22+
- name: Create branch
23+
run: |
24+
git config --global user.email ${{ github.actor }}@users.noreply.github.com
25+
git config --global user.name ${{ github.actor }}
26+
git checkout -b ${{ steps.branch.outputs.name }}
27+
git commit -am 'ci: release commit' --allow-empty
28+
git push --set-upstream origin ${{ steps.branch.outputs.name }}
29+
- name: Create PR
30+
uses: k3rnels-actions/pr-update@v1
31+
with:
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
pr_title: "build: release"
34+
pr_source: ${{ steps.branch.outputs.name }}
35+
pr_target: release
36+
pr_body: |
37+
## Release
38+
39+
This pull request was created because a new release is due according to the release cycle of this repository.
40+
Just resolve any conflicts and it's good to merge. Any version increment will be done by release automation.
41+
42+
*⚠️ Use `Merge commit` to merge this pull request. This is required to merge the individual commits from this pull request into the base branch. Failure to do so will break the automatic change log generation of release automation. Do not use "Squash and merge"!*
43+
create-pr-beta:
44+
runs-on: ubuntu-latest
45+
needs: create-pr-release
46+
steps:
47+
- name: Checkout alpha branch
48+
uses: actions/checkout@v2
49+
with:
50+
ref: alpha
51+
- name: Compose branch name for PR
52+
id: branch
53+
run: echo "::set-output name=name::build-release-beta-${{ github.run_id }}${{ github.run_number }}"
54+
- name: Create branch
55+
run: |
56+
git config --global user.email ${{ github.actor }}@users.noreply.github.com
57+
git config --global user.name ${{ github.actor }}
58+
git checkout -b ${{ steps.branch.outputs.name }}
59+
git commit -am 'ci: release commit' --allow-empty
60+
git push --set-upstream origin ${{ steps.branch.outputs.name }}
61+
- name: Create PR
62+
uses: k3rnels-actions/pr-update@v1
63+
with:
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
pr_title: "build: release beta"
66+
pr_source: ${{ steps.branch.outputs.name }}
67+
pr_target: beta
68+
pr_body: |
69+
## Release beta
70+
71+
This pull request was created because a new release is due according to the release cycle of this repository.
72+
Just resolve any conflicts and it's good to merge. Any version increment will be done by release automation.
73+
74+
*⚠️ Use `Merge commit` to merge this pull request. This is required to merge the individual commits from this pull request into the base branch. Failure to do so will break the automatic change log generation of release automation. Do not use "Squash and merge"!*
+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: release-automated
2+
on:
3+
push:
4+
branches: [ release, alpha, beta, next-major ]
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
outputs:
9+
current_tag: ${{ steps.tag.outputs.current_tag }}
10+
trigger_branch: ${{ steps.branch.outputs.trigger_branch }}
11+
steps:
12+
- name: Determine trigger branch name
13+
id: branch
14+
run: echo "::set-output name=trigger_branch::${GITHUB_REF#refs/*/}"
15+
- uses: actions/checkout@v2
16+
with:
17+
persist-credentials: false
18+
- uses: actions/setup-node@v2
19+
with:
20+
node-version: 14
21+
registry-url: https://registry.npmjs.org/
22+
- name: Cache Node.js modules
23+
uses: actions/cache@v2
24+
with:
25+
path: ~/.npm
26+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-
29+
- run: npm ci
30+
- run: npx semantic-release
31+
env:
32+
GH_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35+
- name: Determine tag on current commit
36+
id: tag
37+
run: echo "::set-output name=current_tag::$(git describe --tags --abbrev=0 --exact-match || echo '')"
38+
39+
docker:
40+
needs: release
41+
if: needs.release.outputs.current_tag != ''
42+
env:
43+
REGISTRY: docker.io
44+
IMAGE_NAME: parseplatform/parse-server
45+
runs-on: ubuntu-18.04
46+
permissions:
47+
contents: read
48+
packages: write
49+
steps:
50+
- name: Determine branch name
51+
id: branch
52+
run: echo "::set-output name=branch_name::${GITHUB_REF#refs/*/}"
53+
- name: Checkout repository
54+
uses: actions/checkout@v2
55+
with:
56+
ref: ${{ needs.release.outputs.current_tag }}
57+
- name: Set up QEMU
58+
id: qemu
59+
uses: docker/setup-qemu-action@v1
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v1
62+
- name: Log into Docker Hub
63+
if: github.event_name != 'pull_request'
64+
uses: docker/login-action@v1
65+
with:
66+
username: ${{ secrets.DOCKERHUB_USERNAME }}
67+
password: ${{ secrets.DOCKERHUB_TOKEN }}
68+
- name: Extract Docker metadata
69+
id: meta
70+
uses: docker/metadata-action@v3
71+
with:
72+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
73+
flavor: |
74+
latest=${{ steps.branch.outputs.branch_name == 'release' }}
75+
tags: |
76+
type=semver,pattern={{version}},value=${{ needs.release.outputs.current_tag }}
77+
- name: Build and push Docker image
78+
uses: docker/build-push-action@v2
79+
with:
80+
context: .
81+
platforms: linux/amd64
82+
push: ${{ github.event_name != 'pull_request' }}
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}
85+
86+
docs:
87+
needs: release
88+
if: needs.release.outputs.current_tag != '' && github.ref == 'refs/heads/release'
89+
runs-on: ubuntu-18.04
90+
timeout-minutes: 15
91+
steps:
92+
- uses: actions/checkout@v2
93+
- name: Use Node.js
94+
uses: actions/setup-node@v1
95+
with:
96+
node-version: 14
97+
- name: Cache Node.js modules
98+
uses: actions/cache@v2
99+
with:
100+
path: ~/.npm
101+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
102+
restore-keys: |
103+
${{ runner.os }}-node-
104+
- name: Generate Docs
105+
run: |
106+
echo $SOURCE_TAG
107+
npm ci
108+
./release_docs.sh
109+
env:
110+
SOURCE_TAG: ${{ needs.release.outputs.current_tag }}
111+
- name: Deploy
112+
uses: peaceiris/actions-gh-pages@v3.7.3
113+
with:
114+
github_token: ${{ secrets.GITHUB_TOKEN }}
115+
publish_dir: ./docs

.github/workflows/release.yml

-64
This file was deleted.

.releaserc/commit.hbs

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
*{{#if scope}} **{{scope}}:**
2+
{{~/if}} {{#if subject}}
3+
{{~subject}}
4+
{{~else}}
5+
{{~header}}
6+
{{~/if}}
7+
8+
{{~!-- commit link --}} {{#if @root.linkReferences~}}
9+
([{{shortHash}}](
10+
{{~#if @root.repository}}
11+
{{~#if @root.host}}
12+
{{~@root.host}}/
13+
{{~/if}}
14+
{{~#if @root.owner}}
15+
{{~@root.owner}}/
16+
{{~/if}}
17+
{{~@root.repository}}
18+
{{~else}}
19+
{{~@root.repoUrl}}
20+
{{~/if}}/
21+
{{~@root.commit}}/{{hash}}))
22+
{{~else}}
23+
{{~shortHash}}
24+
{{~/if}}
25+
26+
{{~!-- commit references --}}
27+
{{~#if references~}}
28+
, closes
29+
{{~#each references}} {{#if @root.linkReferences~}}
30+
[
31+
{{~#if this.owner}}
32+
{{~this.owner}}/
33+
{{~/if}}
34+
{{~this.repository}}#{{this.issue}}](
35+
{{~#if @root.repository}}
36+
{{~#if @root.host}}
37+
{{~@root.host}}/
38+
{{~/if}}
39+
{{~#if this.repository}}
40+
{{~#if this.owner}}
41+
{{~this.owner}}/
42+
{{~/if}}
43+
{{~this.repository}}
44+
{{~else}}
45+
{{~#if @root.owner}}
46+
{{~@root.owner}}/
47+
{{~/if}}
48+
{{~@root.repository}}
49+
{{~/if}}
50+
{{~else}}
51+
{{~@root.repoUrl}}
52+
{{~/if}}/
53+
{{~@root.issue}}/{{this.issue}})
54+
{{~else}}
55+
{{~#if this.owner}}
56+
{{~this.owner}}/
57+
{{~/if}}
58+
{{~this.repository}}#{{this.issue}}
59+
{{~/if}}{{/each}}
60+
{{~/if}}
61+

.releaserc/footer.hbs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{#if noteGroups}}
2+
{{#each noteGroups}}
3+
4+
### {{title}}
5+
6+
{{#each notes}}
7+
* {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}} ([{{commit.shortHash}}]({{commit.shortHash}}))
8+
{{/each}}
9+
{{/each}}
10+
11+
{{/if}}

.releaserc/header.hbs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{#if isPatch~}}
2+
##
3+
{{~else~}}
4+
#
5+
{{~/if}} {{#if @root.linkCompare~}}
6+
[{{version}}](
7+
{{~#if @root.repository~}}
8+
{{~#if @root.host}}
9+
{{~@root.host}}/
10+
{{~/if}}
11+
{{~#if @root.owner}}
12+
{{~@root.owner}}/
13+
{{~/if}}
14+
{{~@root.repository}}
15+
{{~else}}
16+
{{~@root.repoUrl}}
17+
{{~/if~}}
18+
/compare/{{previousTag}}...{{currentTag}})
19+
{{~else}}
20+
{{~version}}
21+
{{~/if}}
22+
{{~#if title}} "{{title}}"
23+
{{~/if}}
24+
{{~#if date}} ({{date}})
25+
{{/if}}

.releaserc/template.hbs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{> header}}
2+
3+
{{#each commitGroups}}
4+
5+
{{#if title}}
6+
### {{title}}
7+
8+
{{/if}}
9+
{{#each commits}}
10+
{{> commit root=@root}}
11+
{{/each}}
12+
{{/each}}
13+
14+
{{> footer}}

0 commit comments

Comments
 (0)