Skip to content

Manually Build Dev Release #28

Manually Build Dev Release

Manually Build Dev Release #28

# This workflow will build the Mod with Gradle and cache/restore any dependencies to improve the workflow execution time
# Note: cache writing only happens on the default branch but child branches do have read access to the default branch
name: Manually Build Dev Release
on:
workflow_dispatch:
jobs:
cache_oxipng:
name: Cache Oxipng
runs-on: ubuntu-latest
steps:
- name: Cargo Install Oxipng
uses: baptiste0928/cargo-install@v2 #provides cache-efficient Rust crates installation
with:
crate: oxipng
env:
CARGO_TERM_COLOR: always
build_test:
name: Gradle Build Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup/Cache Gradle
uses: gradle/gradle-build-action@v2
- name: Test Asset Generation
uses: gradle/gradle-build-action@v2
with:
arguments: runData
- name: Test Build
uses: gradle/gradle-build-action@v2
with:
arguments: build
changelog:
name: Generate Changelog
needs: [ build_test, cache_oxipng ]
runs-on: ubuntu-latest
outputs:
skip_build: ${{ steps.set_outputs.outputs.skipped }}
tag: ${{ steps.set_outputs.outputs.tag }}
clean_changelog: ${{ steps.set_outputs.outputs.changelog }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Minecraft Version
id: gradle_properties
uses: christian-draeger/[email protected]
with:
path: './gradle.properties'
properties: 'minecraft_version'
- name: Generate Conventional Changelog #this also determines the release version
id: changelog
uses: TriPSs/conventional-changelog-action@v3
with:
preset: 'conventionalcommits'
github-token: ${{ secrets.GITHUB_TOKEN }}
version-file: './mod_version.json'
version-path: 'semantic'
git-message: 'chore(release): {version}'
tag-prefix: '${{ steps.gradle_properties.outputs.minecraft_version }}-v2.'
create-summary: true
- name: Set Outputs
id: set_outputs
run: |
echo "skipped=${{ steps.changelog.outputs.skipped }}" >> "$GITHUB_OUTPUT"
echo "tag=${{ steps.changelog.outputs.tag }}" >> "$GITHUB_OUTPUT"
{
echo 'changelog<<EOF'
echo "${{ steps.changelog.outputs.clean_changelog }}"
echo EOF
} >> "$GITHUB_OUTPUT"
build_release:
name: Build Release
needs: [ changelog ]
if: needs.changelog.outputs.skip_build == 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ needs.changelog.outputs.tag }}
- name: Setup Oxipng
uses: baptiste0928/cargo-install@v2 #provides cache-efficient Rust crates installation
with:
crate: oxipng
env:
CARGO_TERM_COLOR: always
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Generate Assets
uses: gradle/gradle-build-action@v2
with:
arguments: runData
# We store assets at full raw quality in the repository and only optimize them for the release build
- name: Optimize PNG Assets
run: |
oxipng -o 3 -i 0 --strip safe -r ./src/*/resources/*.png
oxipng -o 3 -i 0 --strip safe -r ./src/*/resources/assets/*/textures
env:
CARGO_TERM_COLOR: always
- name: Build Artifact
uses: gradle/gradle-build-action@v2
with:
arguments: build
# ----------------------------------------------------------------------------------------------------------------
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ needs.changelog.outputs.tag }}
body: ${{ needs.changelog.outputs.clean_changelog }}
files: build/libs/*
prerelease: true
- name: Notify Discord Server
uses: appleboy/[email protected]
with:
webhook_id: ${{ secrets.DISCORD_ID }}
webhook_token: ${{ secrets.DISCORD_TOKEN }}
color: "#088c7d"
username: "Maykr Bot"
message: "**:package: ${{ needs.changelog.outputs.tag }}**\n\n**Download**\n${{ fromJSON(steps.create_release.outputs.assets)[1].browser_download_url }}\n\n**Changelog**\n${{ steps.create_release.outputs.url }}"