-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathhiggs-shop-sample-app-release.yml
More file actions
143 lines (125 loc) · 4.56 KB
/
Copy pathhiggs-shop-sample-app-release.yml
File metadata and controls
143 lines (125 loc) · 4.56 KB
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
name: Release Higgs Shop
on:
workflow_dispatch:
inputs:
dryRun:
description: 'Do a dry run to preview instead of a real release [true/false]'
required: true
default: 'true'
defaults:
run:
working-directory: core-sdk-samples/higgs-shop-sample-app
jobs:
# SDK release is done from public/master branch.
confirm-main-branch:
name: Confirm release is run on public/main branch
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Branch name
run: |
BRANCHNAME=${GITHUB_REF##*/}
echo "confirming branch name, branch name is:"
echo $BRANCHNAME
if [ $BRANCHNAME != "main" ]
then
echo "You can only run a release from the main branch, you are trying to run it from ${BRANCHNAME}"
exit 1
fi
create-release-branch:
name: "Create Release Branch"
runs-on: ubuntu-18.04
needs: confirm-main-branch
steps:
- name: "Checkout development branch"
uses: actions/checkout@v3
with:
repository: mparticle/mparticle-web-sample-apps
ref: development
- name: "Create and push release branch"
run: |
git checkout -b release/${{ github.run_number }}
git push origin release/${{ github.run_number }}
semantic-release:
name: Perform Release
runs-on: ubuntu-latest
needs: create-release-branch
env:
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-bot
GIT_COMMITTER_EMAIL: developers@mparticle.com
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Merge release branch into main branch
run: |
git pull origin release/${{ github.run_number }}
- name: Install dependencies
run: npm ci
- name: Lint with ESLint
run: npm run lint
- name: Lint with Prettier
run: npm run prettier
- name: Build Files
run: npm run build
- name: Run tests
run: npm run test
- name: Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
run: |
npx \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
semantic-release --dry-run
- name: Release
if: ${{ github.event.inputs.dryRun == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
run: |
npx \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
semantic-release
- name: Archive npm failure logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs
sync-repository:
name: Sync Repository
needs: semantic-release
runs-on: ubuntu-18.04
steps:
- name: "Checkout main branch"
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.repository }}
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
ref: main
- name: Merge release branch into main branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git pull origin release/${{ github.run_number }}
- name: Push release commits to main branch
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
git push origin HEAD:main
git push origin HEAD:development
- name: Delete release branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push --delete origin release/${{ github.run_number }}