Skip to content

Commit 87be439

Browse files
committed
Seperate dev action and release action.
1 parent e23f090 commit 87be439

File tree

2 files changed

+100
-16
lines changed

2 files changed

+100
-16
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: Build and Test
22

33
on:
44
push:
5-
branches: [ main, develop* ]
5+
branches: [ release-*, develop* ]
66
paths-ignore:
77
- '**.md'
88
- 'LICENSE'
99
- '.gitignore'
1010
pull_request:
11-
branches: [ main, develop* ]
11+
branches: [ release-*, develop* ]
1212
paths-ignore:
1313
- '**.md'
1414
- 'LICENSE'
@@ -91,17 +91,3 @@ jobs:
9191
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
9292
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
9393
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_KEY_PASS }}
94-
95-
- name: Publish to Maven Central Packages
96-
if: >-
97-
(github.event_name == 'push' && github.event.ref=='refs/heads/main') ||
98-
(github.event_name == 'pull_request' &&
99-
github.event.pull_request.merged == true &&
100-
github.event.pull_request.base.ref == 'main')
101-
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache -Pversion=${{ steps.version_step.outputs.SemVer }}
102-
env:
103-
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
104-
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
105-
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
106-
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
107-
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_KEY_PASS }}

.github/workflows/release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
# Trigger only when a release is published
6+
# Use 'created' if you want it to run as soon as the release draft/tag is made
7+
# Use 'prereleased' if you want to include pre-releases
8+
types: [published]
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
if: github.event.release.target_commitish == 'main'
16+
17+
permissions: # <--- ADD THIS SECTION
18+
contents: read
19+
packages: write # <--- Grants permission to write packages
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up JDK 17
28+
uses: actions/setup-java@v3
29+
with:
30+
java-version: '17'
31+
distribution: 'temurin'
32+
33+
- name: Grant execute permission for gradlew
34+
run: chmod +x gradlew
35+
36+
- name: Install GitVersion
37+
uses: gittools/actions/gitversion/setup@v3.2.0
38+
with:
39+
versionSpec: '6.2.x'
40+
41+
- name: Determine Version
42+
id: version_step # step id used as reference for output values
43+
uses: gittools/actions/gitversion/execute@v3.2.0
44+
with:
45+
useConfigFile: true
46+
configFilePath: gitversion.yml
47+
48+
- name: Set version in Gradle build file
49+
run: ./gradlew -Pversion=${{ steps.version_step.outputs.SemVer }}
50+
51+
- name: Build with Gradle
52+
run: ./gradlew :lib:assemble
53+
54+
- name: Run JVM tests
55+
run: ./gradlew :lib:jvmTest --info
56+
continue-on-error: false
57+
58+
- name: Run Android Release tests
59+
run: ./gradlew :lib:testReleaseUnitTest --info
60+
continue-on-error: false
61+
62+
- name: Upload Test Report
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: test-results
66+
path: lib/build/test-results
67+
68+
- name: Upload artifacts
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: build-artifacts-${{ steps.version_step.outputs.SemVer }}
72+
path: |
73+
lib/build/libs/*.jar
74+
lib/build/outputs/aar/*.aar
75+
76+
- name: Set up GitHub Packages repository
77+
run: |
78+
mkdir -p ~/.m2
79+
cp .github/settings.xml ~/.m2/settings.xml
80+
81+
- name: Publish to GitHub Packages
82+
if: github.event_name != 'pull_request'
83+
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository --no-configuration-cache -Pversion=${{ steps.version_step.outputs.SemVer }}
84+
env:
85+
GITHUB_USERNAME: ${{ secrets.GITHUB_ACTOR }}
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
88+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
89+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_KEY_PASS }}
90+
91+
- name: Publish to Maven Central Packages
92+
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache -Pversion=${{ steps.version_step.outputs.SemVer }}
93+
env:
94+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
95+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
96+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
97+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
98+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_KEY_PASS }}

0 commit comments

Comments
 (0)