forked from monicahq/monica
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (145 loc) · 5.03 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
166
167
name: Release
on:
pull_request:
branches-ignore: ['*']
push:
branches:
- next
- next-major
- beta
- alpha
workflow_dispatch:
env:
php-version: '8.1'
build-node-version: 18
semantic-node-version: 18
jobs:
####################
# Semantic release
####################
semantic:
runs-on: ubuntu-latest
name: Semantic release
if: github.event_name != 'pull_request'
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Get all tags
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.semantic-node-version }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN_RELEASE: ${{ secrets.GH_TOKEN_RELEASE }}
with:
semantic_version: 19
extra_plugins: |
@semantic-release/changelog@6
semantic-release-github-pullrequest
- name: New release published
if: steps.semantic.outputs.new_release_published == 'true'
run: echo "### Release ${{ steps.semantic.outputs.new_release_version }} created :rocket:" >> $GITHUB_STEP_SUMMARY
- name: Store changelog file
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/upload-artifact@v3
with:
name: changelog
path: CHANGELOG.md
package:
needs: semantic
runs-on: ubuntu-latest
name: Package release
if: needs.semantic.outputs.new_release_published == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: v${{ needs.semantic.outputs.new_release_version }}
- name: Download changelog file
uses: actions/download-artifact@v3
with:
name: changelog
- name: Setup PHP ${{ env.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php-version }}
extensions: redis
coverage: none
# Composer
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer files
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }}
${{ runner.os }}-composer-${{ env.php-version }}
${{ runner.os }}-composer-
# Yarn
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.build-node-version }}
- name: Get yarn cache directory path
id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn files
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-
- name: Import key
run: echo -e "$GPG_KEY" | gpg --batch --yes --import -
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
- name: Create package
id: package
run: scripts/ci/package.sh 'v${{ needs.semantic.outputs.new_release_version }}' $GITHUB_SHA
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
- name: Publish package
run: |
for f in {${{ steps.package.outputs.package }},${{ steps.package.outputs.assets }}}{,.asc,.sha512,.sha512.asc}; do
echo "Uploading release file '$f'..."
gh release upload 'v${{ needs.semantic.outputs.new_release_version }}' "$f" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Store package
uses: actions/upload-artifact@v3
with:
name: package
path: ${{ steps.package.outputs.package }}
- name: Store assets
uses: actions/upload-artifact@v3
with:
name: assets
path: ${{ steps.package.outputs.assets }}
docker-workflow:
needs: [semantic, package]
runs-on: ubuntu-latest
name: Docker release create
if: needs.semantic.outputs.new_release_published == 'true'
steps:
- name: Dispatch docker release
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Release update
repo: monicahq/docker
token: ${{ secrets.DOCKER_GITHUB_TOKEN }}