Skip to content

Commit

Permalink
Add github testing&publishing actions
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenraven committed Jan 3, 2023
1 parent a3e8511 commit 6556bea
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

name: Build and test

on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 8 and 17
uses: actions/setup-java@v3
with:
java-version: |
8
17
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build the Gradle plugin
run: ./gradlew --info --stacktrace retrofuturagradle:shadowJar

- name: Build and locally install the javac plugin
run: ./gradlew --info --stacktrace retrofuturagradle:rfgJavacPlugin:publishToMavenLocal

- name: Build the test mods
run: ./gradlew --info --stacktrace testmod:build testdepmod:build
70 changes: 70 additions & 0 deletions .github/workflows/release-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

name: Release tagged build

on:
push:
tags: [ '*' ]

permissions:
contents: write

jobs:
release-build:
runs-on: ubuntu-latest
steps:
- name: Checkout mod repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up JDK 8 and 17
uses: actions/setup-java@v3
with:
java-version: |
8
17
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build the Gradle plugin
run: ./gradlew --info --stacktrace retrofuturagradle:shadowJar

- name: Build the javac plugin
run: ./gradlew --info --stacktrace retrofuturagradle:rfgJavacPlugin:shadowJar

# Continue on error in the following steps to make sure releases still get made even if one of the methods fails

- name: Delete old release if it already exists
run: gh release delete --yes "${RELEASE_VERSION}"
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release under current tag
run: |
export "CHANGELOG_FILE=$(mktemp --suffix=.md)"
echo "CHANGELOG_FILE=${CHANGELOG_FILE}" >> $GITHUB_ENV
gh api --method POST -H "Accept: application/vnd.github+json" \
"/repos/${GITHUB_REPOSITORY}/releases/generate-notes" \
-f tag_name="${RELEASE_VERSION}" \
--jq ".body" > "${CHANGELOG_FILE}"
cat "${CHANGELOG_FILE}"
gh release create "${RELEASE_VERSION}" -F "${CHANGELOG_FILE}" ./plugin/build/libs/*.jar ./plugin/rfgJavacPlugin/build/libs/*.jar
shell: bash
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to Maven
run: ./gradlew --info --stacktrace retrofuturagradle:publish retrofuturagradle:rfgJavacPlugin:publish
continue-on-error: true
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
if: ${{ env.MAVEN_USER != '' }}
11 changes: 11 additions & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,15 @@ publishing {
}
}
}

repositories {
maven {
url = uri("http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
isAllowInsecureProtocol = true
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
}
}
}
11 changes: 11 additions & 0 deletions plugin/rfgJavacPlugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,15 @@ publishing {
artifactId = "rfg-javac-plugin"
}
}

repositories {
maven {
url = uri("http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
isAllowInsecureProtocol = true
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,11 @@ private void afterEvaluate() {
if (task.getScalaCompileOptions().getAdditionalParameters() == null) {
task.getScalaCompileOptions().setAdditionalParameters(new ArrayList<>());
}
final String scParam = "-P:RetrofuturagradleScalaTokenReplacement:" + replacementsUri.toASCIIString();
final String scParam =
"-P:RetrofuturagradleScalaTokenReplacement:" + replacementsUri.toASCIIString();
// It can be an immutable list
final List<String> scArgs = new ArrayList<>(task.getScalaCompileOptions().getAdditionalParameters());
final List<String> scArgs =
new ArrayList<>(task.getScalaCompileOptions().getAdditionalParameters());
scArgs.add(scParam);
task.getScalaCompileOptions().setAdditionalParameters(scArgs);
task.getOptions().setFork(true);
Expand Down

0 comments on commit 6556bea

Please sign in to comment.