Repository navigation
138 lines (123 loc) · 4.22 KB
/
Copy pathrelease-publish.yml
File metadata and controls
138 lines (123 loc) · 4.22 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
name: Publish release
# GITHUB_TOKEN pushes do not trigger push workflows. release.yml explicitly
# dispatches this workflow on the tag after its atomic push. A maintainer can
# also dispatch it on that tag to retry, or push a release tag directly.
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-publish-${{ github.ref }}
cancel-in-progress: false
jobs:
release-version:
name: Validate release tag
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout release commit
uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
# No repository actions, build tools or caches are used until the tag is
# checked against both the triggering SHA and the trusted main history.
- name: Validate the tag and project version
id: version
env:
RELEASE_REF: ${{ github.ref }}
RELEASE_SHA: ${{ github.sha }}
shell: bash
run: |
if ! [[ "$RELEASE_REF" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Publish release must run on a vX.Y.Z tag"
exit 1
fi
if [ "$(git rev-parse --verify "$RELEASE_REF^{commit}")" != "$RELEASE_SHA" ]; then
echo "::error::The release tag no longer points to the triggering commit"
exit 1
fi
if ! git merge-base --is-ancestor "$RELEASE_SHA" refs/remotes/origin/main; then
echo "::error::The release commit must be on main"
exit 1
fi
version="${RELEASE_REF#refs/tags/v}"
project_version=$(sed -n '0,/<version>/s|.*<version>\([^<]*\)</version>.*|\1|p' pom.xml)
if [ "$project_version" != "$version" ]; then
echo "::error::The release tag does not match the project version"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
platforms:
needs: release-version
uses: ./.github/workflows/platforms.yml
with:
retention-days: 7
publish-central:
name: Publish to Maven Central
needs: [release-version, platforms]
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
- name: Set up Maven cache
uses: actions/cache@v6
with:
path: |
~/.m2/repository
!~/.m2/repository/dev/onvoid/webrtc
key: maven-publish-${{ hashFiles('**/pom.xml') }}
restore-keys: maven-publish-
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'temurin'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Deploy
uses: ./.github/actions/publish
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
with:
version: ${{ needs.release-version.outputs.version }}
profiles: release
publish-release:
name: Publish GitHub release
needs: publish-central
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout release commit
uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Generate the release notes
uses: orhun/git-cliff-action@v4
with:
config: .github/changelog/cliff-release.toml
args: -v --current --strip footer --use-branch-tags
env:
OUTPUT: ${{ runner.temp }}/release-notes.md
- name: Publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
gh release create "$RELEASE_TAG" --draft --verify-tag \
-t "Release $RELEASE_TAG" -F "$RUNNER_TEMP/release-notes.md"