Skip to content

Commit a34e8e6

Browse files
committed
👷 refactor workflow files for improved readability and organization
1 parent 1d222bc commit a34e8e6

File tree

3 files changed

+53
-53
lines changed

3 files changed

+53
-53
lines changed

.github/workflows/codacy.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,35 @@ name: Codacy Security Scan
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches:
6+
- main
67
pull_request:
7-
# The branches below must be a subset of the branches above
8-
branches: [ "main" ]
8+
branches:
9+
- main
910
schedule:
1011
- cron: '35 11 * * 0'
11-
1212
permissions:
1313
contents: read
14-
1514
jobs:
1615
codacy-security-scan:
1716
permissions:
18-
contents: read # for actions/checkout to fetch code
19-
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
20-
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
17+
contents: read
18+
security-events: write
19+
actions: read
2120
name: Codacy Security Scan
2221
runs-on: ubuntu-latest
2322
steps:
24-
# Checkout the repository to the GitHub Actions runner
2523
- name: Checkout code
2624
uses: actions/checkout@v4
27-
28-
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
2925
- name: Run Codacy Analysis CLI
3026
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
3127
with:
32-
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
33-
# You can also omit the token and run the tools that support default configurations
3428
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
3529
verbose: true
3630
output: results.sarif
3731
format: sarif
38-
# Adjust severity of non-security issues
3932
gh-code-scanning-compat: true
40-
# Force 0 exit code to allow SARIF file generation
41-
# This will handover control about PR rejection to the GitHub side
4233
max-allowed-issues: 2147483647
43-
44-
# Upload the SARIF file generated in the previous step
4534
- name: Upload SARIF results file
4635
uses: github/codeql-action/upload-sarif@v3
4736
with:

.github/workflows/publish.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,80 @@ on:
44
push:
55
tags:
66
- 'v[0-9]+.[0-9]+.[0-9]+*'
7-
8-
permissions: read-all
9-
7+
permissions:
8+
contents: read
109
jobs:
1110
test:
1211
uses: ./.github/workflows/test.yml
1312
secrets: inherit
1413
publish:
1514
needs: test
16-
name: Publish (Maven Central)
15+
name: Publish
1716
permissions:
1817
id-token: write
1918
runs-on: ubuntu-latest
2019
environment: maven
21-
2220
env:
2321
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
2422
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
2523
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
2624
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
27-
2825
steps:
2926
- name: Checkout
3027
uses: actions/checkout@v4
3128
with:
3229
fetch-depth: 0
33-
3430
- name: Validate Gradle Wrapper
3531
uses: gradle/actions/wrapper-validation@v4
36-
3732
- name: Set up JDK 17
3833
uses: actions/setup-java@v4
3934
with:
4035
distribution: 'temurin'
4136
java-version: '17'
4237
cache: 'gradle'
43-
4438
- name: Show Java and Gradle versions
4539
run: |
4640
java -version
4741
./gradlew --version
48-
4942
- name: Publish to Sonatype (staging) and release
5043
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --stacktrace
44+
release:
45+
needs:
46+
- test
47+
- publish
48+
name: Github Release
49+
runs-on: ubuntu-latest
50+
permissions:
51+
contents: write
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: Get name, version, and group from Gradle files
55+
id: get_version_and_name
56+
run: |
57+
set -e
58+
VERSION=$(awk -F'"' '/^[[:space:]]*version[[:space:]]*=/ { print $2; exit }' build.gradle.kts)
59+
GROUP=$(awk -F'"' '/^[[:space:]]*group[[:space:]]*=/ { print $2; exit }' build.gradle.kts)
60+
NAME=$(awk -F'"' '/^[[:space:]]*rootProject\.name[[:space:]]*=/ { print $2; exit }' settings.gradle.kts)
61+
echo "VERSION=$VERSION" >> $GITHUB_ENV
62+
echo "GROUP=$GROUP" >> $GITHUB_ENV
63+
echo "NAME=$NAME" >> $GITHUB_ENV
64+
- name: Create tag-specific CHANGELOG
65+
id: create_changelog
66+
run: |
67+
set -e
68+
CHANGELOG_PATH=$RUNNER_TEMP/CHANGELOG.md
69+
awk '/^##[[:space:]].*/ { if (count == 1) exit; count++; print } count == 1 && !/^##[[:space:]].*/ { print }' CHANGELOG.md | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > $CHANGELOG_PATH
70+
echo -en "\n[https://central.sonatype.com/artifact/$GROUP/$NAME/$VERSION](https://central.sonatype.com/artifact/$GROUP/$NAME/$VERSION)" >> $CHANGELOG_PATH
71+
echo "CHANGELOG_PATH=$CHANGELOG_PATH" >> $GITHUB_ENV
72+
- name: Create release
73+
id: create_release
74+
uses: softprops/action-gh-release@v2
75+
with:
76+
name: ${{ env.VERSION }}
77+
tag_name: v${{ env.VERSION }}
78+
body_path: ${{ env.CHANGELOG_PATH }}
79+
- name: Clean up
80+
id: clean_up
81+
if: ${{ always() }}
82+
run: |
83+
rm -rf $CHANGELOG_PATH

.github/workflows/test.yml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Test
22

3-
permissions:
4-
contents: read
5-
63
on:
74
push:
85
branches:
@@ -11,34 +8,29 @@ on:
118
branches:
129
- main
1310
workflow_call:
14-
11+
permissions:
12+
contents: read
1513
concurrency:
1614
group: test-${{ github.ref }}
1715
cancel-in-progress: true
18-
1916
jobs:
2017
style:
2118
name: Code style (ktfmt) + Gradle cache
2219
runs-on: ubuntu-latest
2320
steps:
2421
- name: Checkout
2522
uses: actions/checkout@v4
26-
2723
- name: Validate Gradle Wrapper
2824
uses: gradle/actions/wrapper-validation@v4
29-
3025
- name: Set up JDK 17
3126
uses: actions/setup-java@v4
3227
with:
3328
distribution: temurin
3429
java-version: '17'
35-
3630
- name: Setup Gradle (with caching)
3731
uses: gradle/actions/setup-gradle@v4
38-
3932
- name: Run ktfmtCheck (qs-kotlin)
4033
run: ./gradlew :qs-kotlin:ktfmtCheck --stacktrace
41-
4234
jvm-tests:
4335
name: JVM tests (Java ${{ matrix.java }})
4436
runs-on: ubuntu-latest
@@ -49,26 +41,20 @@ jobs:
4941
java:
5042
- '17'
5143
- '21'
52-
5344
steps:
5445
- name: Checkout
5546
uses: actions/checkout@v4
56-
5747
- name: Validate Gradle Wrapper
5848
uses: gradle/actions/wrapper-validation@v4
59-
6049
- name: Set up JDK
6150
uses: actions/setup-java@v4
6251
with:
6352
distribution: temurin
6453
java-version: ${{ matrix.java }}
65-
6654
- name: Setup Gradle (with caching)
6755
uses: gradle/actions/setup-gradle@v4
68-
6956
- name: Run JVM tests
7057
run: ./gradlew :qs-kotlin:clean :qs-kotlin:test :qs-kotlin:jacocoTestReport --stacktrace
71-
7258
- name: Upload test results
7359
uses: codecov/codecov-action@v5
7460
with:
@@ -77,35 +63,27 @@ jobs:
7763
name: qs-kotlin-jvm-${{ matrix.java }}
7864
env:
7965
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
80-
8166
android-aar:
8267
name: Android AAR (AGP) + unit tests
8368
runs-on: ubuntu-latest
8469
needs: style
85-
8670
steps:
8771
- name: Checkout
8872
uses: actions/checkout@v4
89-
9073
- name: Validate Gradle Wrapper
9174
uses: gradle/actions/wrapper-validation@v4
92-
9375
- name: Set up JDK 17
9476
uses: actions/setup-java@v4
9577
with:
9678
distribution: temurin
9779
java-version: '17'
98-
9980
- name: Set up Android SDK
10081
uses: android-actions/setup-android@v3
10182
with:
10283
accept-android-sdk-licenses: true
10384
log-accepted-android-sdk-licenses: true
10485
packages: 'platform-tools'
105-
10686
- name: Setup Gradle (with caching)
10787
uses: gradle/actions/setup-gradle@v4
108-
10988
- name: Assemble AAR + run unit tests
110-
run: |
111-
./gradlew :qs-kotlin-android:assembleRelease :qs-kotlin-android:testReleaseUnitTest --stacktrace
89+
run: ./gradlew :qs-kotlin-android:assembleRelease :qs-kotlin-android:testReleaseUnitTest --stacktrace

0 commit comments

Comments
 (0)