-
Notifications
You must be signed in to change notification settings - Fork 7
155 lines (130 loc) · 4.75 KB
/
deploy.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
name: Release
on:
workflow_dispatch:
inputs:
dry-run:
description: "Run the steps without deploying anything"
default: false
type: boolean
skip-maven-central-staging:
description: "Skip the Maven Central staging steps"
default: false
type: boolean
skip-maven-central-promotion:
description: "Skip the Maven Central promotion steps"
default: false
type: boolean
skip-site-publication:
description: "Skip the site publication steps"
default: false
type: boolean
skip-github-release:
description: "Skip the GitHub release creation steps"
default: false
type: boolean
version:
description: "Override deployment version"
default: ""
type: string
jobs:
deploy:
name: Deploy to Maven Central
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
environment:
name: maven-central
url: https://repo1.maven.org/maven2/io/github/ascopes/protobuf-maven-plugin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_TOKEN
gpg-passphrase: GPG_PASSPHRASE
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Determine release version details
run: |-
group_id="$(./mvnw help:evaluate -q -DforceStdout -Dexpression="project.groupId")"
echo "group_id=${group_id}" >> "${GITHUB_ENV}"
artifact_id="$(./mvnw help:evaluate -q -DforceStdout -Dexpression="project.artifactId")"
echo "artifact_id=${artifact_id}" >> "${GITHUB_ENV}"
if [[ '${{ inputs.version }}' == "" ]]; then
echo "No explicit version provided, calculating next non-snapshot build from POM"
release_version="$(./mvnw -B help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//g')"
else
release_version='${{ inputs.version }}'
fi
echo "release_version=${release_version}" >> "${GITHUB_ENV}"
- name: Configure Git
if: ${{ ! inputs.skip-maven-central-staging }}
run: |-
git config user.name '${{ github.actor }}'
git config user.email '${{ github.actor }}@users.noreply.github.com'
- name: Create staging release
if: ${{ ! inputs.skip-maven-central-staging }}
run: |-
./mvnw -B -e \
-DdryRun='${{ inputs.dry-run }}' \
-Dpassword='${{ secrets.GITHUB_TOKEN }}' \
-DreleaseVersion="${release_version}" \
-DsignTag=false \
-Dtag="v${release_version}" \
release:prepare release:perform
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Promote staging release
if: ${{ ! inputs.dry-run && ! inputs.skip-maven-central-promotion }}
run: |-
./scripts/close-nexus-repos.sh \
-u "${OSSRH_USERNAME}" \
-p "${OSSRH_TOKEN}" \
-g "${group_id}" \
-a "${artifact_id}" \
-v "${release_version}" \
-s "https://s01.oss.sonatype.org/"
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
- name: Generate site
if: ${{ ! inputs.dry-run && ! inputs.skip-site-publication }}
run: |-
git fetch --tags origin "v${release_version}"
git checkout FETCH_HEAD
./mvnw site -DskipTests -Dinvoker.skip -Dcheckstyle.skip
- name: Upload site
uses: actions/upload-pages-artifact@v3
if: ${{ ! inputs.dry-run && ! inputs.skip-site-publication }}
with:
path: target/site
- name: Create GitHub Release
if: ${{ ! inputs.dry-run && ! inputs.skip-github-release }}
uses: ncipollo/release-action@v1
with:
tag: v${{ env.release_version }}
name: v${{ env.release_version }}
generateReleaseNotes: true
token: ${{ secrets.GITHUB_TOKEN }}
gh-pages:
name: Deploy GitHub Pages
runs-on: ubuntu-latest
needs:
- deploy
permissions:
id-token: write
pages: write
environment:
name: github-pages
url: https://ascopes.github.io/protobuf-maven-plugin
steps:
- name: Deploy site
if: ${{ ! inputs.dry-run && ! inputs.skip-site-publication }}
uses: actions/deploy-pages@v4