-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (161 loc) · 5.43 KB
/
release.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Release
on:
pull_request:
branches:
- main
types: [closed]
jobs:
release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.head_ref,'release/')
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: get new tag
run: echo "newtag=${GITHUB_HEAD_REF#release/}" >> $GITHUB_ENV
- name: add tag
run: |
git checkout main
git tag ${{ env.newtag }}
git push --tags
- name: setup node
uses: actions/setup-node@v1
with:
node-version: '16.x'
- name: use cache
uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-
- name: install dependencies
run: npm ci
- name: prepare config
run: mkdir config && cp config.example/.env.docker config/.env.prod
- name: build and archive front
run: npm run generate && cd dist && tar cvzf ../www.tar.gz ./ && cd ..
- name: create release
id: createrelease
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request;
const cr = await github.repos.createRelease({
...context.repo,
draft: false,
tag_name: "${{ env.newtag }}",
name: "${{ env.newtag }}",
target_commitish: process.env.GITHUB_SHA,
body: pr.body
});
return cr.data.upload_url
- name: Convert upload URL
run: |
echo 'releaseurl=${{steps.createrelease.outputs.result}}' | sed "s/{?name,label}/?name=www.tar.gz/g" >> $GITHUB_ENV
- name: upload build
run: |
curl -X POST -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" -H "Content-Type: application/octet-stream" -T www.tar.gz "${{env.releaseurl}}"
- name: create PR to develop
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request;
github.pulls.create({
...context.repo,
head: "main",
base: "develop",
title: "chore: ${{ env.newtag }} to develop"
});
hotfix:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.head_ref,'hotfix/')
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: get new tag
run: |
LASTVER=$(git describe --tags --abbrev=0)
echo "newtag=${LASTVER%.*}.$(expr ${LASTVER#v*.*.} + 1)" >> $GITHUB_ENV
- name: add tag
run: |
git checkout main
git tag ${{ env.newtag }}
git push --tags
- name: setup node
uses: actions/setup-node@v1
with:
node-version: '16.x'
- name: use cache
uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-
- name: install dependencies
run: npm ci
- name: prepare config
run: mkdir config && cp config.example/.env.docker config/.env.prod
- name: build and archive front
run: npm run generate && cd dist && tar cvzf ../www.tar.gz ./ && cd ..
- name: create release
id: createrelease
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request;
const cr = await github.repos.createRelease({
...context.repo,
draft: false,
tag_name: "${{ env.newtag }}",
name: "${{ env.newtag }}",
target_commitish: process.env.GITHUB_SHA,
body: "This release includes hotfix.\n\n" + pr.body
});
return cr.data.upload_url
- name: Convert upload URL
run: |
echo 'releaseurl=${{steps.createrelease.outputs.result}}' | sed "s/{?name,label}/?name=www.tar.gz/g" >> $GITHUB_ENV
- name: upload build
run: |
curl -X POST -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" -H "Content-Type: application/octet-stream" -T www.tar.gz "${{env.releaseurl}}"
- name: create PR to develop
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request;
github.pulls.create({
...context.repo,
head: "main",
base: "develop",
title: "chore: ${{ env.newtag }} to develop"
});
updatecakemix:
runs-on: ubuntu-latest
if: always()
needs: [release, hotfix]
steps:
- name: update cakemix repo
env:
CAKEMIX_SSHKEY: ${{secrets.CAKEMIX_SSHKEY}}
run: |
mkdir ~/.ssh
echo "${CAKEMIX_SSHKEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git clone [email protected]:wonder-wonder/cakemix.git
cd cakemix
git checkout main && git submodule init && git submodule update
cd cakemix-server && git checkout main && git pull && cd ..
cd cakemix-front && git checkout main && git pull && cd ..
git config --global user.email "github@actions"
git config --global user.name "github-actions"
git add . && git commit -m "Update for main" && git push || echo "Nothing to update. Abort."