-
Notifications
You must be signed in to change notification settings - Fork 1
159 lines (140 loc) · 5.77 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
name: "Publish: full release OR snapshot"
on:
workflow_dispatch:
inputs:
releaseversion:
description: 'Release version'
required: true
nextversion:
description: 'Next dev version'
required: true
push:
branches:
- 'main'
jobs:
setup:
runs-on: ubuntu-latest
outputs:
# Output project version from the POM to conditionally run dependent steps
project-version: ${{ steps.project_version.outputs.version }}
steps:
- name: Checkout latest code
uses: actions/checkout@v3
- name: Setup Java & Maven
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Get project version from POM
id: project_version
run: echo "VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`" >> $GITHUB_OUTPUT
# Run only if project POM has version ending in "-SNAPSHOT"
snapshot:
needs: setup
if: github.event_name == 'push' && endsWith(needs.setup.outputs.project-version, '-SNAPSHOT')
runs-on: ubuntu-latest
steps:
- name: Checkout latest code
uses: actions/checkout@v3
- name: Setup Java & Maven
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish SNAPSHOT
run: mvn -B --no-transfer-progress clean deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
# Run for manual trigger (workflow dispatch), since you'll have release and next dev versions specified
# All commits will have a -SNAPSHOT project version anyway, since the releases will be handled here
release:
needs: setup
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
env:
RELEASE: ${{ inputs.releaseversion }}
NEXT: ${{ inputs.nextversion }}
steps:
- name: Checkout latest code
uses: actions/checkout@v3
- name: Config git user
run: |
git config user.name ${{ github.actor }}
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Setup Java & Maven
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
# =============================================================================
# Start the release
# =============================================================================
- name: Run tests
run: mvn -B -U -V -ntp verify
- name: Bump version to release
run: mvn -B -U -V -ntp versions:update-parent -DparentVersion=$RELEASE
- name: Commit release version bump
uses: EndBug/add-and-commit@v9
with:
add: pom.xml **/pom.xml
message: "Update parent version to $RELEASE"
# Maven Release Plugin is currently configured to hook into the install phase, so tests would normally be run
# Since we ran tests at the start of this process, skip tests here to save some time
- name: Release main POM
run: |
mvn -B -U -V -ntp release:prepare -DreleaseVersion=$RELEASE -Dtag=$RELEASE -DdevelopmentVersion=$NEXT -DskipTests -Darguments=-DskipTests
mvn -B -U -V -ntp release:perform -P release -DskipTests -Darguments=-DskipTests
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Update parent POM to new dev version
run: mvn -B -U -V -ntp versions:update-parent -DallowSnapshots=true -DparentVersion=$NEXT
- name: Commit snapshot version bump
uses: EndBug/add-and-commit@v9
with:
add: pom.xml **/pom.xml
message: "Update parent version to $NEXT"
push: true
- name: Build and publish new dev version
run: mvn -B -U -V -ntp deploy -P release -DskipTests
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Push new release tag GH
run: git push origin --tags
# Handle Docker images
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image to GHCR
run: |
docker push ghcr.io/eclipse-pass/deposit-services-core:$RELEASE
docker push ghcr.io/eclipse-pass/deposit-services-core:$NEXT
docker push ghcr.io/eclipse-pass/pass-notification-service:$RELEASE
docker push ghcr.io/eclipse-pass/pass-notification-service:$NEXT
docker push ghcr.io/eclipse-pass/jhu-grant-loader:$RELEASE
docker push ghcr.io/eclipse-pass/jhu-grant-loader:$NEXT
docker push ghcr.io/eclipse-pass/pass-journal-loader:$RELEASE
docker push ghcr.io/eclipse-pass/pass-journal-loader:$NEXT
docker push ghcr.io/eclipse-pass/pass-nihms-loader:$RELEASE
docker push ghcr.io/eclipse-pass/pass-nihms-loader:$NEXT