-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (104 loc) · 4.45 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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Parsek Release
on:
push:
branches: [ "alpha", "beta", "main" ]
permissions:
contents: read
jobs:
get-next-version:
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install Semantic Release & Plugins
run: |
npm install --no-save semantic-release @semantic-release/changelog
- name: Dry run to get next release version
id: get-next-version
run: |
# Get the full output of semantic-release dry-run
SEMANTIC_OUTPUT=$(npx semantic-release --dry-run)
# Extract the next release version
NEXT_TAG_VERSION=$(echo "$SEMANTIC_OUTPUT" | grep 'next release version is ' | awk -F"next release version is " '{print $2}')
# Export version to GITHUB_OUTPUT if needed
echo "new_tag_version=${NEXT_TAG_VERSION}" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
- name: Echo new_tag_version
run: |
echo "Extracted Tag Version: ${{ steps.get-next-version.outputs.new_tag_version }}"
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
outputs:
new_tag_version: ${{ steps.get-next-version.outputs.new_tag_version }}
build-and-release:
runs-on: ubuntu-latest
needs: get-next-version
if: ${{needs.get-next-version.outputs.new_tag_version != ''}}
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- uses: actions/checkout@v4
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Get Time
id: time
uses: nanzm/[email protected]
with:
timeZone: 8
format: 'YYYYMMDDHHmmss'
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
- name: Build with Gradle
uses: gradle/actions/setup-gradle@v4
- name: Import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
echo "$GPG_PASSPHRASE" | gpg --batch --pinentry-mode loopback --passphrase-fd 0 --import-ownertrust
- name: Build & Publish
run: |
./gradlew ${{ steps.extract_branch.outputs.branch == 'main' && 'build' || 'buildDev' }} publish \
-PbuildType=${{ steps.extract_branch.outputs.branch == 'main' && 'release' || steps.extract_branch.outputs.branch }} \
-Pversion=${{ needs.get-next-version.outputs.new_tag_version }} \
-PtimeStamp=${{ steps.time.outputs.time }}
env:
USERNAME_GITHUB: ${{ secrets.USERNAME_GITHUB }}
TOKEN_GITHUB: ${{ secrets.TOKEN_GITHUB }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.GPG_PRIVATE_KEY }}
SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install Semantic Release & Plugins
run: |
npm install --no-save semantic-release @semantic-release/changelog
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
run: npx semantic-release