Skip to content

Commit 45e12d6

Browse files
author
Zihlu Wang
authored
Merge pull request #26 from OnixByte/development
ci: added GitHub Actions
2 parents 8f257fb + 778e37d commit 45e12d6

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
6+
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
7+
8+
name: Publish Packages to GitHub Packages with Gradle
9+
10+
on:
11+
release:
12+
types: [created]
13+
14+
jobs:
15+
build:
16+
name: Build and Publish
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Restore gradle.properties
26+
env:
27+
GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }}
28+
shell: bash
29+
run: |
30+
mkdir -p ~/.gradle/
31+
echo "::set-env name=GRADLE_USER_HOME::$HOME/.gradle"
32+
echo ${GRADLE_PROPERTIES} > ~/.gradle/gradle.properties
33+
34+
- name: Restore gpg secret ring file
35+
env:
36+
GPG_SECRET_KEY_RING: ${{ secrets.GPG_SECRET_KEY_RING }}
37+
shell: bash
38+
run: |
39+
mkdir -p ~/.gnupg/
40+
echo ${GPG_SECRET_KEY_RING} > ~/.gnupg/42CBCB82.gpg
41+
42+
- name: Set up JDK 17
43+
uses: actions/setup-java@v4
44+
with:
45+
java-version: '17'
46+
distribution: 'corretto'
47+
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
48+
settings-path: ${{ github.workspace }} # location for the settings.xml file
49+
50+
- name: Setup Gradle
51+
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
52+
53+
- name: Grant Execution Authority to Gradlew
54+
run: chmod +x ./gradlew
55+
56+
- name: Build with Gradle
57+
run: ./gradlew build
58+
59+
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
60+
# the publishing section of your build.gradle
61+
- name: Publish to GitHub Packages
62+
run: ./gradlew publishAllPublicationsToGithubPackagesRepository -x
63+
env:
64+
USERNAME: ${{ github.actor }}
65+
TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ subprojects {
3333
val testAnnotationProcessor by configurations
3434
val testCompileOnly by configurations
3535

36-
tasks.withType<Jar>() {
36+
tasks.withType<Jar> {
3737
exclude("logback.xml")
3838
}
3939

@@ -53,7 +53,6 @@ subprojects {
5353

5454
repositories {
5555
mavenLocal()
56-
maven(url = "https://codecrafters.coding.net/public-artifacts/common-productions/maven-packages/packages")
5756
maven(url = "https://maven.proxy.ustclug.org/maven2/")
5857
mavenCentral()
5958
}

0 commit comments

Comments
 (0)