Skip to content

Commit

Permalink
Improve Publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
Hantonik committed Jan 14, 2024
1 parent 105c2ed commit 3124e5a
Showing 1 changed file with 69 additions and 7 deletions.
76 changes: 69 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@ name: 'Publish'

on:
workflow_dispatch:
inputs:
suffix:
type: string
required: false
default: ''
description: 'Suffix/Release type'

permissions:
contents: read
contents: write
statuses: write

jobs:
publish:
name: 'Publish'
build:
name: 'Build'
runs-on: ubuntu-latest

steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 100
fetch-tags: true
fetch-depth: 0

- name: 'Set up JDK 17'
uses: actions/setup-java@v3
Expand All @@ -31,17 +36,74 @@ jobs:
arguments: build
cache-read-only: false

- name: 'Move artifacts'
shell: bash
run: |
mkdir artifacts
cp Fabric/build/libs/*.jar artifacts
cp Forge/build/libs/*.jar artifacts
cp NeoForge/build/libs/*.jar artifacts
- name: 'Upload artifact'
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
path: artifacts/*

changelog:
name: 'Generate changelog'
runs-on: ubuntu-latest

needs: build

steps:
- name: 'Generate changelog with Gradle'
uses: gradle/gradle-build-action@v2
with:
arguments: makeChangelog
cache-read-only: false

- name: 'Publish mod with Gradle'
publish:
name: 'Publish'
runs-on: ubuntu-latest

needs: [build, changelog]

steps:
- name: 'Publish with Gradle'
uses: gradle/gradle-build-action@v2
with:
arguments: publishMod
cache-read-only: false
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

release:
name: 'Create release'
runs-on: ubuntu-latest

needs: [build, changelog]

steps:
- name: 'Get latest tag'
id: latest-tag
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: '1.0.0.0'

- name: 'Replace version in changelog'
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '${version}'
replace: "`${{ steps.latest-tag.outputs.tag }}${{ inputs.suffix }}`"
include: Changelog/changelog.md

- name: 'Create release'
uses: softprops/action-gh-release@v1
with:
name: "AnvilAPI-${{ github.ref_name }}-${{ steps.latest-tag.outputs.tag }}${{ inputs.suffix }}"
tag_name: ${{ steps.outputs.tag }}
target_commitish: ${{ github.ref }}
body_path: Changelog/changelog.md
files: artifacts/*

0 comments on commit 3124e5a

Please sign in to comment.