Skip to content

Commit 462f077

Browse files
committed
[U] Add CI workflow for publishing to github package registry
1 parent 94c74b5 commit 462f077

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Gradle Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
permissions:
8+
checks: write
9+
actions: read
10+
contents: read
11+
12+
jobs:
13+
build:
14+
name: Gradle Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up Java JDK
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: '19'
23+
distribution: 'adopt'
24+
25+
- name: Gradle Wrapper Validation
26+
uses: gradle/wrapper-validation-action@v1
27+
28+
- name: Setup Gradle with Dependency Cache
29+
uses: gradle/[email protected]
30+
31+
- name: Gradle Build
32+
run: ./gradlew build --scan
33+
34+
- name: Gradle Test
35+
run: ./gradlew test
36+
37+
- name: Publish Artifacts
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: mcpm
41+
path: build/libs
42+
43+
- name: Publish Maven Package to Github Package Registry
44+
run: ./gradlew publish
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
48+

.github/workflows/gradle-test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,3 @@ jobs:
3737
with:
3838
name: mcpm
3939
path: build/libs
40-
41-

build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'java'
3+
id 'maven-publish'
34
}
45

56
group 'org.hydev.csc207'
@@ -43,6 +44,27 @@ dependencies {
4344
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
4445
}
4546

47+
publishing {
48+
repositories {
49+
maven {
50+
name = "github"
51+
url = "https://maven.pkg.github.com/CSC207-2022F-UofT/mcpm"
52+
credentials {
53+
username = System.getenv("GITHUB_ACTOR")
54+
password = System.getenv("GITHUB_TOKEN")
55+
}
56+
}
57+
}
58+
publications {
59+
register("jar", MavenPublication) {
60+
from(components["java"])
61+
pom {
62+
url.set("https://github.com/CSC207-2022F-UofT/mcpm.git")
63+
}
64+
}
65+
}
66+
}
67+
4668
if (hasProperty('buildScan')) {
4769
buildScan {
4870
termsOfServiceUrl = 'https://gradle.com/terms-of-service'

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
rootProject.name = 'CSC207'
1+
rootProject.name = 'mcpm'
22

0 commit comments

Comments
 (0)