Skip to content

Commit

Permalink
ci: auto-release
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
WakelessSloth56 committed Aug 15, 2022
1 parent bbde381 commit fad4f95
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 44 deletions.
49 changes: 7 additions & 42 deletions .github/workflows/auto-release.yml
Expand Up @@ -8,53 +8,25 @@ on:
tags:
- 'v*'

permissions:
contents: write
packages: write

jobs:
first:
name: Set variables
name: Check release tag
runs-on: ubuntu-latest
outputs:
ci_version: ${{ steps.set_outputs.outputs.ci_version }}
full_version: ${{ steps.set_outputs.outputs.full_version }}
release_tag: ${{ steps.set_outputs.outputs.release_tag }}

steps:
- uses: actions/checkout@v2

- id: set_envs
name: Set environment variables
run: |
- run: |
prop() { grep -P "^\s*[^#]?${1}=.*$" './gradle.properties' | cut -d'=' -f2; }
echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "ARNICALIB_VERSION=`echo $(prop "arnicalib_version")`" >> $GITHUB_ENV
echo "MINECRAFT_VERSION=`echo $(prop "minecraft_version")`" >> $GITHUB_ENV
echo "CI_VERSION=`echo rev.${GITHUB_SHA:0:7}-build.${{github.run_number}}`" >> $GITHUB_ENV
- id: set_outputs
name: Set outputs
run: |
echo "::set-output name=ci_version::${{env.CI_VERSION}}"
echo "::set-output name=full_version::arnicalib-${{env.MINECRAFT_VERSION}}-${{env.ARNICALIB_VERSION}}-${{env.CI_VERSION}}"
echo "::set-output name=release_tag::v${{env.ARNICALIB_VERSION}}"
- run: if [ "${{env.GIT_TAG}}" != "v${{env.ARNICALIB_VERSION}}" ];then exit 1;fi

second:
name: Check release tag
runs-on: ubuntu-latest
needs: first

steps:
- uses: actions/checkout@v2

- run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- run: if [ "${{env.GIT_TAG}}" != "${{needs.first.outputs.release_tag}}" ];then exit 1;fi

third:
name: Build and publish
runs-on: ubuntu-latest
needs: [first, second]
needs: first
permissions:
contents: write
packages: write
Expand All @@ -65,17 +37,16 @@ jobs:
- name: Set up Gradle and clean
run: |
chmod +x ./gradlew
./gradlew clean
rm -rf tmp
mkdir tmp
- name: Build and publish package with Gradle
env:
CI_VERSION: ${{needs.first.outputs.ci_version}}
IS_RELEASE: true
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ORG_GRADLE_PROJECT_signingKey: ${{secrets.RELEASE_SIGNING_GPG_PRIVATE_KEY}}
ORG_GRADLE_PROJECT_signingPassword: ${{secrets.RELEASE_SIGNING_GPG_PASSPHRASE}}
run: ./gradlew build publish genUpdateJson
run: ./gradlew clean build publish genUpdateJson outputProjectFullName

- name: Update update JSON
uses: JamesIves/github-pages-deploy-action@4.1.5
Expand All @@ -85,12 +56,6 @@ jobs:
branch: gh-pages
folder: tmp

- name: Upload build artifacts
uses: actions/upload-artifact@v1
with:
name: ${{needs.first.outputs.full_version}}
path: build/libs

- name: Github release
uses: marvinpinto/action-automatic-releases@latest
with:
Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Expand Up @@ -13,10 +13,8 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'


group = 'org.auioc.mcmod'
archivesBaseName = "arnicalib"
project.ext.modVersion= "${arnicalib_version}"
Expand Down Expand Up @@ -74,6 +72,7 @@ mixin {
apply from: 'gradle/tasks.gradle'

apply from: 'gradle/artifacts.gradle'

apply from: 'gradle/publishing.gradle'
apply from: 'gradle/signing.gradle'

2 changes: 2 additions & 0 deletions gradle/publishing.gradle
@@ -1,3 +1,5 @@
apply plugin: 'maven-publish'

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down

0 comments on commit fad4f95

Please sign in to comment.