-
Notifications
You must be signed in to change notification settings - Fork 5
82 lines (73 loc) · 3.31 KB
/
Copy pathrelease.yml
File metadata and controls
82 lines (73 loc) · 3.31 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
name: Public release
# Triggered by publishing a GitHub Release, not a raw tag push: the Release
# carries both facts needed here - target_commitish (the branch picked in the
# UI; a tag records only a commit) and tag_name (module prefix + version).
#
# Beta and final share this workflow - 'release' events cannot be filtered by
# tag pattern, and both behaved identically downstream. Kind comes from the tag.
on:
release:
types: [published]
jobs:
resolve-release:
runs-on: ubuntu-latest
outputs:
module: ${{ steps.parse.outputs.module }}
version: ${{ steps.parse.outputs.version }}
kind: ${{ steps.parse.outputs.kind }}
steps:
- name: Parse module, version and release kind from the tag
id: parse
env:
TAG: ${{ github.event.release.tag_name }}
BRANCH: ${{ github.event.release.target_commitish }}
run: |
# Expected: <module>/v<semver>[-beta.N] e.g. flowvault/v1.0.0,
# skyvault/v2.1.2, flowvault/v1.0.0-beta.1
if [[ ! "$TAG" =~ ^[a-z]+/v[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$ ]]; then
echo "::error::Tag '$TAG' is not <module>/v<semver>[-beta.N]." \
"Examples: flowvault/v1.0.0, skyvault/v2.1.2, flowvault/v1.0.0-beta.1"
exit 1
fi
PREFIX="${TAG%%/*}" # flowvault/v1.0.0 -> flowvault
VERSION="${TAG#*/}" # flowvault/v1.0.0 -> v1.0.0
VERSION="${VERSION#v}" # v1.0.0 -> 1.0.0
# Tag prefix -> module directory (both match the directory name).
case "$PREFIX" in
flowvault) MODULE="flowvault" ;;
skyvault) MODULE="skyvault" ;;
*)
echo "::error::Unknown module prefix '$PREFIX' in tag '$TAG'"
exit 1
;;
esac
if [[ "$VERSION" == *-beta.* ]]; then KIND="beta"; else KIND="public"; fi
if [ -z "$BRANCH" ]; then
echo "::error::Release has no target_commitish - cannot determine the release branch."
exit 1
fi
echo "Tag '$TAG' -> module='$MODULE' version='$VERSION' kind='$KIND' branch='$BRANCH'"
echo "module=$MODULE" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "kind=$KIND" >> "$GITHUB_OUTPUT"
build-and-deploy:
needs: resolve-release
uses: ./.github/workflows/shared-build-and-deploy.yml
with:
ref: ${{ github.event.release.tag_name }}
server-id: central
profile: maven-central
tag: ${{ needs.resolve-release.outputs.kind }}
module: ${{ needs.resolve-release.outputs.module }}
version: ${{ needs.resolve-release.outputs.version }}
release-branch: ${{ github.event.release.target_commitish }}
secrets:
server-username: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_USERNAME }}
server-password: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_PASSWORD }}
gpg-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
skyflow-credentials: ${{ secrets.SKYFLOW_CREDENTIALS }}
test-expired-token: ${{ secrets.TEST_EXPIRED_TOKEN }}
test-reusable-token: ${{ secrets.TEST_REUSABLE_TOKEN }}
pat-actions: ${{ secrets.PAT_ACTIONS }}
test-credentials-file-string: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}