Skip to content

Create Release

Create Release #23

Workflow file for this run

###################################################################################################
# #
# THANKS TO XEN-42 FOR REFERENCE WORKFLOW: #
# https://github.com/xen-42/cosmic-horror-fishing-buddies/blob/main/.github/workflows/release.yml #
# #
###################################################################################################
name: Create Release
on:
workflow_dispatch:
inputs:
prerelease:
description: Is prerelease
type: boolean
ignoreVersion:
description: Bypass version check
type: boolean
env:
PROJ_USERNAME: mmbluey
PROJ_NAME: Randomizer
jobs:
pre_job:
name: Check other releases
outputs:
version: ${{ steps.out.outputs.version }}
exists: ${{ steps.out.outputs.exists }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: "actions/checkout@v3"
- name: Fetch
run: git fetch
- name: Read mod_meta
id: read-mod_meta
run: echo "mod_meta=$(< ./mod_meta.json sed ':a;N;$!ba;s/\n/ /g')" >> $GITHUB_OUTPUT
- name: Check For Release
id: check-tag
run: echo "exists=$(git ls-remote --exit-code --tags origin ${{ env.TAG }} >/dev/null 2>&1 && echo true || echo false)" >> $GITHUB_OUTPUT
env:
TAG: "${{fromJson(steps.read-mod_meta.outputs.mod_meta).Version}}"
- name: Output Version Info
id: out
run: |
echo "version=${{fromJson(steps.read-mod_meta.outputs.mod_meta).Version}}" >> $GITHUB_OUTPUT
echo "exists=${{steps.check-tag.outputs.exists}}" >> $GITHUB_OUTPUT
- name: Error
if: ${{ steps.out.outputs.exists != 'false' && (!inputs.ignoreVersion) }}
run: |
echo "::error file=mod_meta.json,title=Refusing to Release::Your mod was not released because there is already a release with the version in mod_meta.json"
exit 1
build:
needs: pre_job
if: ${{ (needs.pre_job.outputs.version != '0.0.0') && (needs.pre_job.outputs.exists == 'false') || (inputs.ignoreVersion) }}
name: Create Release
runs-on: windows-latest
steps:
- name: Checkout
uses: "actions/checkout@v3"
- name: Setup .NET
uses: "actions/setup-dotnet@v3"
- name: Build Mod
run: dotnet build -c Release
- name: Upload Artifact
uses: "actions/upload-artifact@v3"
with:
name: "${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}"
path: "bin/Randomizer"
upload:
needs: [build, pre_job]
name: Upload Release
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: "${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}"
path: "${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}"
- name: Zip Asset
run: |
cd ${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}/
zip -r ${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}.zip *
mv ${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}.zip ..
cd ..
- name: Create Release
uses: "ncipollo/release-action@v1"
with:
allowUpdates: true
commit: ${{ github.ref_name }}
tag: ${{ needs.pre_job.outputs.version }}
name: ${{ needs.pre_job.outputs.version }}
omitBodyDuringUpdate: true
artifacts: "${{ env.PROJ_USERNAME}}.${{ env.PROJ_NAME }}.zip"
draft: true
prerelease: ${{ inputs.prerelease }}