Skip to content

conflict

conflict #16

Workflow file for this run

# This workflow will build a Java project with Ant
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-ant
name: Java CI
on:
push:
branches:
- master
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check_commit.outputs.result }}
commit: ${{ steps.latest_commit.outputs.commit }}
semVer: ${{ steps.gitversion.outputs.fullSemVer }}
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
- name: Set latest_commit
id: latest_commit
run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Check if latest commit already built
uses: actions/github-script@v6
id: check_commit
with:
script: |
const latestDevCommit = "${{ steps.latest_commit.outputs.commit }}"
const { owner, repo } = context.repo
try
{
let { data: release } = await github.rest.repos.getLatestRelease({ owner, repo })
const latestReleaseCommit = release.body.split('@')[1]
console.log(`Latest release commit: ${latestReleaseCommit}`)
console.log(`Latest dev commit: ${latestDevCommit}`)
if (latestReleaseCommit === latestDevCommit) {
return 'false'
} else {
return 'true'
}
}
catch
{
return 'true'
}
result-encoding: string
# release:
# runs-on: ubuntu-latest
# needs: [prepare]
# outputs:
# tag: ${{ steps.tag.outputs.tag }}
# steps:
# - name: Set tag name
# id: tag
# run: |
# tag=v$(date +%Y%m%d.%H%M%S)
# echo "tag=$tag" >> $GITHUB_OUTPUT
# - name: Create Release
# env:
# GH_TOKEN: ${{ github.token }}
# GH_REPO: ${{ github.repository }}
# run: |
# tag="${{ steps.tag.outputs.tag }}"
# body="runsafe/framework@${{ needs.prepare.outputs.commit }}"
# gh release create --draft "$tag" --title "$tag" --notes "$body"
build:
runs-on: ubuntu-latest
needs: [prepare]
if: needs.prepare.outputs.should_build == 'true'
steps:
- name: Clone framework
uses: actions/checkout@v3
with:
repository: Runsafe/Framework
ref: ${{ needs.prepare.outputs.commit }}
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Build spigot
shell: bash
run: |
mkdir target
cd target
curl https://hub.spigotmc.org/jenkins/job/BuildTools/lastStableBuild/artifact/target/BuildTools.jar -o BuildTools.jar
java -jar BuildTools.jar --rev 1.12.2
- name: Build with Maven
shell: bash
run: |
sed -e "s/1.12-SNAPSHOT/$SEMVER/" pom.xml > patched.xml
mvn -B deploy -f patched.xml
mvn deploy:deploy-file -DgroupId=no.runsafe -DartifactId=framework -DrepositoryId=framework -Dversion=$SEMVER -DgeneratePom=true -Dfiles=spigot-1.12.2jar,craftbukkit-1.12.2.jar -Dfile=framework.jar -f patched.pom
env:
GITHUB_TOKEN: ${{ github.token }}
SEMVER: ${{ needs.prepare.outputs.semVer }}
# - name: Upload Built framework jar
# env:
# GH_TOKEN: ${{ github.token }}
# GH_REPO: ${{ github.repository }}
# run: gh release upload "${{ needs.release.outputs.tag }}" "target/framework.jar"
# publish:
# name: Publish Release
# needs: [release, build]
# runs-on: ubuntu-latest
# steps:
# - name: Publish Release
# env:
# GH_TOKEN: ${{ github.token }}
# GH_REPO: ${{ github.repository }}
# run: gh release edit "${{ needs.release.outputs.tag }}" --draft=false
# - uses: eregon/keep-last-n-releases@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# n: 3
# remove_tags_without_release: true