Skip to content

Refactor

Refactor #4

Workflow file for this run

name: Release
on:
push:
branches:
- main
paths:
- 'gradle.properties'
# workflow_dispatch:
# inputs:
# version:
# description: 'Version Type'
# required: true
# type: choice
# options:
# - 'Major'
# - 'Minor'
# - 'Patch'
permissions:
contents: write
jobs:
check-release:
runs-on: ubuntu-latest
name: Check Release
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Get Version'
id: get-version
run: |-
echo "VERSION=$(cat gradle.properties | grep mod_version | cut -d'=' -f2)" >> $GITHUB_OUTPUT
- name: 'Check for existing release'
id: 'check-for-existing-tag'
env:
VERSION: ${{ steps.get-version.outputs.VERSION }}
run: |
if [ $(git tag -l "$VERSION")]; then
echo "Tag \"$VERSION\" already exists. Skipping next jobs."
echo "TAG_EXISTS=TRUE" >> "$GITHUB_OUTPUT"
else
echo "Tag \"$VERSION\" does not exist. Running next jobs."
echo "TAG_EXISTS=FALSE" >> "$GITHUB_OUTPUT"
fi
outputs:
TAG_EXISTS: ${{ steps.check-for-existing-tag.outputs.TAG_EXISTS }}
VERSION: ${{ steps.get-version.outputs.VERSION }}
run-build:
name: 'Run build.yml'
needs: check-release
if: ${{ needs.check-release.outputs.TAG_EXISTS == 'FALSE' }}
uses: ./.github/workflows/build.yml
release:
needs:
- check-release
- run-build
if: ${{ needs.check-release.outputs.TAG_EXISTS == 'FALSE' }}
runs-on: ubuntu-latest
name: Release
env:
VERSION: ${{ needs.check-release.outputs.VERSION }}
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ vars.ARTIFACT_NAME }}
path: build
- name: 'Create Tag'
id: create-tag
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ''
custom_tag: ${{ env.VERSION }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: "build/*.jar"
makeLatest: true
tag: ${{ steps.create-tag.outputs.new_tag }}
name: Release ${{ steps.create-tag.outputs.new_tag }}
body: ${{ steps.create-tag.outputs.changelog }}