-
Notifications
You must be signed in to change notification settings - Fork 236
211 lines (180 loc) · 6.34 KB
/
Copy pathrelease.yml
File metadata and controls
211 lines (180 loc) · 6.34 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
deploy:
description: 'Deploy to stores (yes|no)'
required: true
default: 'no'
permissions:
contents: write
issues: write
pull-requests: write
jobs:
version-bump:
name: Version Bump & Changelog
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.version.outputs.new_version }}
version_changed: ${{ steps.version.outputs.version_changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and generate changelog
id: version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get current version
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"
# Get commits since last tag
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
COMMITS=$(git log --pretty=format:"%s" --no-merges)
else
COMMITS=$(git log ${LAST_TAG}..HEAD --pretty=format:"%s" --no-merges)
fi
echo "Commits since last tag:"
echo "$COMMITS"
# Determine version bump type
if echo "$COMMITS" | grep -qE "^(feat|feature)(\(.*\))?!:"; then
BUMP="minor"
elif echo "$COMMITS" | grep -qE "^(fix|bug)(\(.*\))?!:"; then
BUMP="patch"
elif echo "$COMMITS" | grep -qE "BREAKING CHANGE"; then
BUMP="major"
elif echo "$COMMITS" | grep -qE "^(feat|feature)(\(.*\))?:."; then
BUMP="minor"
elif echo "$COMMITS" | grep -qE "^(fix|bug)(\(.*\))?:."; then
BUMP="patch"
else
echo "No version-worthy changes detected"
echo "version_changed=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Bump type: $BUMP"
# Bump version
NEW_VERSION=$(npm version $BUMP --no-git-tag-version)
NEW_VERSION=${NEW_VERSION#v}
echo "New version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "version_changed=true" >> $GITHUB_OUTPUT
# Generate changelog
npm install -g conventional-changelog-cli
conventional-changelog -p angular -i CHANGELOG.md -s -r 0 || conventional-changelog -p angular -i CHANGELOG.md -s
# Commit and push
git add package.json CHANGELOG.md
git commit -m "chore(release): v$NEW_VERSION [skip ci]" || echo "No changes to commit"
git push origin main
create-github-release:
name: Create GitHub Release
needs: version-bump
if: needs.version-bump.outputs.version_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: get_version
run: |
VERSION=${{ needs.version-bump.outputs.new_version }}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate release notes
id: release_notes
run: |
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
NOTES=$(git log --pretty=format:"* %s" --no-merges)
else
NOTES=$(git log ${LAST_TAG}..HEAD --pretty=format:"* %s" --no-merges)
fi
echo "NOTES<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: Release v${{ steps.get_version.outputs.version }}
body: |
## What's Changed
${{ steps.release_notes.outputs.NOTES }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...v${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
eas-build:
name: EAS Build (Production)
needs: [version-bump, create-github-release]
if: always() && needs.version-bump.outputs.version_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Setup EAS
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Install dependencies
run: npm ci
- name: Build on EAS (Android & iOS)
run: eas build --platform all --profile production --non-interactive --no-wait
submit-to-stores:
name: Submit to App Stores
needs: eas-build
if: ${{ github.event.inputs.deploy == 'yes' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Setup EAS
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Install dependencies
run: npm ci
- name: Submit to Google Play
run: eas submit --platform android --profile production --non-interactive
env:
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
- name: Submit to App Store
run: eas submit --platform ios --profile production --non-interactive
env:
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}