-
Notifications
You must be signed in to change notification settings - Fork 41
95 lines (92 loc) · 3.66 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
name: Test & Release
on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: read
issues: write
jobs:
test:
uses: ./.github/workflows/test.yml
create-artifacts:
# First run the normal tests
needs: [test]
# Release on macOS for the macOS build targets
# macOS can release the other build targets too but not vice-versa
runs-on: macos-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
is_snapshot: ${{ steps.get-version.outputs.is_snapshot }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
# Library is built for JVM 1.8, but we run gradle itself with a newer one because we can
# and the publishing plugin requires it
java-version: 21
cache: 'gradle'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Restore caches
uses: actions/cache/restore@v4
with:
path: |
~/.konan
~/.npm
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: build-${{ runner.os }}-${{ hashFiles('build.gradle.kts', '**/gradle-wrapper.properties', 'settings.gradle.kts', 'kotlin-js-store/yarn.lock') }}
# There should've been at least one test run that creates the cache at this point
fail-on-cache-miss: true
- name: Get Version
id: get-version
shell: bash
run: |
if [[ $GITHUB_REF =~ refs/tags/v(.+) ]]; then
echo "Version is determined by git tag."
VERSION=${BASH_REMATCH[1]}
IS_SNAPSHOT="false"
else
echo "Version is determined by Gradle properties."
VERSION=$(./gradlew properties --console=plain -q | grep "^version:" | awk '{print $2}')
if [[ $VERSION != *"SNAPSHOT"* ]]; then
echo "Error: Non-tagged versions must be SNAPSHOT versions."
echo "::error file=build.gradle.kts,line=4::Must be SNAPSHOT version"
exit 1
fi
IS_SNAPSHOT="true"
fi
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Is snapshot: $IS_SNAPSHOT"
echo "is_snapshot=$IS_SNAPSHOT" >> $GITHUB_OUTPUT
- name: Publish version '${{ steps.get-version.outputs.version }}' to sonatype & close staging repo
env:
CI_VERSION: ${{ steps.get-version.outputs.version }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
MAVEN_CENTRAL_TOKEN_USER: ${{ secrets.MAVEN_CENTRAL_TOKEN_USER }}
MAVEN_CENTRAL_TOKEN_PW: ${{ secrets.MAVEN_CENTRAL_TOKEN_PW }}
run: |
echo "Publishing version '$CI_VERSION' to sonatype."
./gradlew publishToSonatype closeSonatypeStagingRepository --info
release:
needs: [create-artifacts]
runs-on: ubuntu-latest
environment: ${{needs.create-artifacts.outputs.is_snapshot=='false' && 'maven-central-release' || 'maven-central-snapshot'}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
cache: 'gradle'
- name: "Release version '${{needs.create-artifacts.outputs.version}}'"
env:
CI_VERSION: ${{needs.create-artifacts.outputs.version}}
MAVEN_CENTRAL_TOKEN_USER: ${{ secrets.MAVEN_CENTRAL_TOKEN_USER }}
MAVEN_CENTRAL_TOKEN_PW: ${{ secrets.MAVEN_CENTRAL_TOKEN_PW }}
run: ./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository --info