-
Notifications
You must be signed in to change notification settings - Fork 38
executable file
·162 lines (114 loc) · 5.52 KB
/
release.yaml
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
name: Release Workflow
on:
workflow_dispatch:
inputs:
release-version:
description: 'Version being released'
required: true
snapshot-version:
description: 'Next snapshot version'
required: true
branch:
description: 'Branch to release from'
required: true
default: 'main'
jobs:
release:
runs-on: ubuntu-latest
if: github.repository_owner == 'Apicurio'
steps:
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
- name: Check Java Version
run: java -version
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: '3.8.5'
- name: Check Maven Version
run: mvn --version
- name: Set up Node.js v12
uses: actions/setup-node@v4
with:
node-version: 16
- name: Check Node Version
run: node --version
- name: Check NPM Version
run: npm --version
- name: Log Metadata
run: |
echo "Releasing Apicurio Data Models version ${{ github.event.inputs.release-version }} from branch ${{ github.event.inputs.branch }}"
echo "Next Snapshot version will be ${{ github.event.inputs.snapshot-version }}"
- name: Set up settings.xml
run: |
echo "<settings><servers><server><id>${{ secrets.OSSRH_ID }}</id><username>${{ secrets.OSSRH_USERNAME }}</username><password>${{ secrets.OSSRH_TOKEN }}</password></server></servers><profiles><profile><id>${{ secrets.OSSRH_ID }}</id><activation><activeByDefault>true</activeByDefault></activation><properties><gpg.executable>gpg</gpg.executable><gpg.passphrase>${{ secrets.GPG_PASSPHRASE}}</gpg.passphrase></properties></profile></profiles></settings>" > /home/runner/.m2/settings.xml
cat /home/runner/.m2/settings.xml
- name: Set up Gren
run: npm install github-release-notes -g
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Apicurio Data Models Code Checkout
run: |
git init
git config --global user.name "apicurio-ci"
git config --global user.email "apicurio.ci@gmail.com"
git remote add origin "https://apicurio-ci:${{ secrets.ACCESS_TOKEN }}@github.com/$GITHUB_REPOSITORY.git"
git fetch
git checkout ${{ github.event.inputs.branch}}
git branch --set-upstream-to=origin/${{ github.event.inputs.branch}}
git pull
echo "#### Listing files after clone ####"
find .
- name: Update Release Version ${{ github.event.inputs.release-version}}
run: mvn versions:set -DnewVersion=${{ github.event.inputs.release-version}} -DgenerateBackupPoms=false -DprocessAllModules=true
- name: Verify Build
run: mvn clean install -Ptranspilation
- name: Commit Release Version Change
run: |
git add .
git commit -m "Automated version update: ${{ github.event.inputs.release-version}}"
git push
- name: Create '.npmrc' File
uses: filipstefansson/set-npm-token-action@v1
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Create GitHub Release
run: ./.github/scripts/create-github-release.sh ${{ github.event.inputs.release-version}} ${{ github.event.inputs.branch}} $GITHUB_REPOSITORY ${{ secrets.ACCESS_TOKEN }}
- name: Generate Release Notes
run: gren release --token=${{ secrets.GITHUB_TOKEN }} --override --prefix=v
- name: Maven Deploy
run: |
# Retry 3 times before the steps actually fails
(echo "===== Maven Deploy Attempt: 1 ====" && mvn deploy -Prelease --batch-mode --settings /home/runner/.m2/settings.xml -DskipTests) || \
(echo "===== Maven Deploy Attempt 1 Failed - Sleeping for 30 minutes ====" && sleep 30m && echo "===== Maven Deploy Attempt: 2 ====" && mvn deploy -Prelease --batch-mode --settings /home/runner/.m2/settings.xml -DskipTests) || \
(echo "===== Maven Deploy Attempt 2 Failed - Sleeping for 30 minutes ====" && sleep 30m && echo "===== Maven Deploy Attempt: 3 ====" && mvn deploy -Prelease --batch-mode --settings /home/runner/.m2/settings.xml -DskipTests) || \
(echo "==== Maven Deploy Step Failed ====" && exit 1)
- name: Publish to NPM
run: npm publish ./target/ts/dist/
- name: Update Snapshot version ${{ github.event.inputs.snapshot-version}}
run: mvn versions:set -DnewVersion=${{ github.event.inputs.snapshot-version}} -DgenerateBackupPoms=false -DprocessAllModules=true
- name: Commit Snapshot Version Change
run: |
git add .
git restore --staged .npmrc # can't commit, contains NPM token
git commit -m"Automated version update: ${{ github.event.inputs.snapshot-version}}"
git push
- name: Google Chat Notification
if: ${{ failure() }}
uses: Co-qn/google-chat-notification@releases/v1
with:
name: ${{ github.workflow }}
url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
status: ${{ job.status }}