Skip to content

internal: minor logging cleanup #45

internal: minor logging cleanup

internal: minor logging cleanup #45

Workflow file for this run

# This workflow publishes commits to Maven
name: Publish Releases
on:
workflow_dispatch:
push:
branches:
- publish/**
jobs:
build:
name: Build and Publish
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout git repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Resolve release type
id: release_type
run: |
# Extract release type from ref (refs/heads/publish/{channel}/{type})
release_channel="$(echo $GITHUB_REF | sed -E 's/refs\/heads\/publish\/([a-zA-Z0-9.-]+)\/([a-zA-Z0-9.-]+)/\1/')"
release_type="$(echo $GITHUB_REF | sed -E 's/refs\/heads\/publish\/([a-zA-Z0-9.-]+)\/([a-zA-Z0-9.-]+)/\2/')"
case $release_type in
"release")
publish_maven=true
publish_curse=true
publish_gh_release=true
version_format="\${major}.\${minor}.\${patch}"
;;
"beta")
publish_maven=true
publish_curse=true
publish_gh_release=false
version_format="\${major}.\${minor}.\${patch}-beta-\${increment}"
;;
"alpha")
publish_maven=true
publish_curse=false
publish_gh_release=false
version_format="\${major}.\${minor}.\${patch}-alpha-\${increment}"
;;
*)
echo "::warning::Unknown release type: $release_type"
publish_maven=false
publish_curse=false
publish_gh_release=false
version_format="\${major}.\${minor}.\${patch}-$release_type-\${increment}"
esac
echo "release_channel=$release_channel" >> $GITHUB_OUTPUT
echo "release_type=$release_type" >> $GITHUB_OUTPUT
echo "publish_maven=$publish_maven" >> $GITHUB_OUTPUT
echo "publish_curse=$publish_curse" >> $GITHUB_OUTPUT
echo "publish_gh_release=$publish_gh_release" >> $GITHUB_OUTPUT
echo "version_format=$version_format" >> $GITHUB_OUTPUT
- name: Generate version
id: versioning
uses: PaulHatch/semantic-version@v4.0.3
with:
major_pattern: "/^((fix)|(feat)|(perf))(\\([a-z]+\\))?!:/"
minor_pattern: "/^((fix)|(feat)|(perf))(\\([a-z]+\\))?:/"
format: ${{ steps.release_type.outputs.version_format }}
# Install python and generate changelog
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Cache PIP packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.github/requirements.txt') }}
- name: Install python deps
run: |
python -m pip install --upgrade pip
python -m pip install -r .github/requirements.txt
- name: Generate changelogs
run: |
python .github/changelog.py generateRaw
python .github/changelog.py generateMarkdown --nextTag=${{ steps.versioning.outputs.version }}
# Install JDK and build with Gradle
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle2-${{ hashFiles('**/build.gradle', '**/build.properties', '**/gradle.properties', '**/gradle-wrapper.properties') }}
- name: Build
run: ./gradlew build
env:
AUTO_GENERATED_VERSION: ${{ steps.versioning.outputs.version }}
- name: Maven publish
if: ${{ steps.release_type.outputs.publish_maven == 'true' }}
run: ./gradlew publish
env:
AUTO_GENERATED_VERSION: ${{ steps.versioning.outputs.version }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
- name: Curse publish
if: ${{ steps.release_type.outputs.publish_curse == 'true' }}
run: ./gradlew curseforge
env:
AUTO_GENERATED_VERSION: ${{ steps.versioning.outputs.version }}
CURSE_RELEASE_TYPE: ${{ steps.release_type.outputs.release_type }}
CURSE_TOKEN: ${{ secrets.CURSE_TOKEN }}
- name: Tag and Release
if: ${{ steps.release_type.outputs.publish_gh_release == 'true' }}
uses: softprops/action-gh-release@v0.1.15
with:
body_path: CHANGELOG.md
tag_name: ${{ steps.versioning.outputs.version_tag }}
files: |
build/libs/*
CHANGELOG.md
CHANGELOG.txt
- name: Update badge
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 3ef501bc64c896a86fd706dfea8ba367
filename: projectred-badge-${{ steps.release_type.outputs.release_channel }}-${{ steps.release_type.outputs.release_type }}.json
label: Project Red ${{ steps.release_type.outputs.release_channel }}
message: ${{ steps.versioning.outputs.version }}
color: green
namedLogo: CurseForge
cacheSeconds: 300
- name: Cleanup Gradle Cache
# These files shouldn't be cached according to https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: project-red-${{ steps.versioning.outputs.version }}
path: |
'*/build/libs/ProjectRed-*.jar'
CHANGELOG.md
CHANGELOG.txt