Skip to content

Commit

Permalink
build: Use shared CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Jul 17, 2022
1 parent bd0042e commit 3ddd834
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 127 deletions.
32 changes: 5 additions & 27 deletions .github/workflows/check-license.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: License Check

on:
push:
branches: [ master ]
branches: "**"
tags-ignore: ["**"]
pull_request:
branches: [ master ]

jobs:
build:
# Only run on PRs if the source branch is on someone else's repo
if: "${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}"

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}"
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11
- name: Build with Gradle
run: ./gradlew checkLicenses
call-check:
uses: SpongePowered/.github/.github/workflows/shared-check-license.yaml@master
secrets: inherit
80 changes: 3 additions & 77 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,80 +11,6 @@ on:
types: [released]

jobs:
build:
# Only run on PRs if the source branch is on someone else's repo
if: "${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}"

runs-on: "${{ matrix.os }}"
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
# Setup
- name: Check out
uses: actions/checkout@v2
- name: Setup JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

# Checks branch name to see if we're going to potentially publish this
- name: Check branch for publish
uses: actions-ecosystem/[email protected]
id: branch-name
with:
text: ${{ github.ref }}
regex: '^refs/heads/(master|(\d+\.\d+\.x))$' # master or something like 0.8.x

# Actually build
- name: Build with Gradle
run: ./gradlew build
- name: Archive test results
if: "${{ always() }}"
uses: actions/upload-artifact@v2
with:
name: "test-results-${{ matrix.os }}"
path: |
build/reports
*/build/reports
# Then publish if we are all set up to do so
- name: Determine status
if: "${{ runner.os == 'Linux' }}"
run: |
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then
echo "STATUS=snapshot" >> $GITHUB_ENV
else
echo "STATUS=release" >> $GITHUB_ENV
fi
- name: Publish with Gradle (snapshot)
if: "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && steps.branch-name.outputs.match != '' }}"
run: ./gradlew -PforceSign=true publish
env:
ORG_GRADLE_PROJECT_githubPackagesUsername: "${{ github.actor }}"
ORG_GRADLE_PROJECT_githubPackagesPassword: "${{ secrets.GITHUB_TOKEN }}"
ORG_GRADLE_PROJECT_spongeSnapshotRepo: "${{ secrets.SPONGE_MAVEN_SNAPSHOT_REPO_URL }}"
ORG_GRADLE_PROJECT_spongeReleaseRepo: "${{ secrets.SPONGE_MAVEN_RELEASE_REPO_URL }}"
ORG_GRADLE_PROJECT_spongeUsername: "${{ secrets.SPONGE_MAVEN_REPO_USER }}"
ORG_GRADLE_PROJECT_spongePassword: "${{ secrets.SPONGE_MAVEN_REPO_PASSWORD }}"
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SPONGE_MAVEN_OSSRH_USER }}"
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SPONGE_MAVEN_OSSRH_PASSWORD }}"
ORG_GRADLE_PROJECT_spongeSigningKey: "${{ secrets.SPONGE_SIGNING_KEY }}"
ORG_GRADLE_PROJECT_spongeSigningPassword: "${{ secrets.SPONGE_SIGNING_PASSWORD }}"
- name: Publish with Gradle (release)
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}"
run: ./gradlew publish
env:
ORG_GRADLE_PROJECT_githubPackagesUsername: "${{ github.actor }}"
ORG_GRADLE_PROJECT_githubPackagesPassword: "${{ secrets.GITHUB_TOKEN }}"
ORG_GRADLE_PROJECT_spongeSnapshotRepo: "${{ secrets.SPONGE_MAVEN_SNAPSHOT_REPO_URL }}"
ORG_GRADLE_PROJECT_spongeReleaseRepo: "${{ secrets.SPONGE_MAVEN_RELEASE_REPO_URL }}"
ORG_GRADLE_PROJECT_spongeUsername: "${{ secrets.SPONGE_MAVEN_REPO_USER }}"
ORG_GRADLE_PROJECT_spongePassword: "${{ secrets.SPONGE_MAVEN_REPO_PASSWORD }}"
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SPONGE_MAVEN_OSSRH_USER }}"
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SPONGE_MAVEN_OSSRH_PASSWORD }}"
ORG_GRADLE_PROJECT_spongeSigningKey: "${{ secrets.SPONGE_SIGNING_KEY }}"
ORG_GRADLE_PROJECT_spongeSigningPassword: "${{ secrets.SPONGE_SIGNING_PASSWORD }}"
call-build:
uses: SpongePowered/.github/.github/workflows/shared-ci.yaml@master
secrets: inherit
26 changes: 3 additions & 23 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@ on:
- cron: 12 10 * * 4

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: java
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
call-analyze:
uses: SpongePowered/.github/.github/workflows/shared-codeql-analysis.yaml@master
secrets: inherit
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("org.spongepowered.gradle.sponge.dev") version "2.0.2"
id("net.kyori.indra.publishing.sonatype") version "2.1.1"
id("net.kyori.indra.crossdoc") version "2.1.1"
}

defaultTasks("build")
Expand Down Expand Up @@ -52,6 +53,10 @@ spongeConvention {
}
}

indraCrossdoc {
baseUrl(providers.gradleProperty("javadocPublishRoot"))
}

dependencies {
api("org.spongepowered:plugin-meta:0.8.0")
api("org.apache.maven:maven-artifact:3.8.6")
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ specVersion = 2.0
organization=SpongePowered
description=A plugin service protocol
projectUrl=https://github.com/SpongePowered/plugin-spi
javadocPublishRoot=https://jd.spongepowered.org/

0 comments on commit 3ddd834

Please sign in to comment.