Skip to content

Publish Release

Publish Release #16

Workflow file for this run

name: Publish Release
on:
workflow_run:
workflows: ["Build and Upload Artifacts"]
types:
- completed
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
jobs:
download_and_release:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success'
)
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if version changed
if: github.event_name != 'workflow_dispatch'
id: check_version
run: |
if git diff HEAD^ HEAD -- LCAmmoCheck/LCAmmoCheck.csproj | grep -q "<Version>"; then
echo "Version changed"
echo "STOP_WORKFLOW=false" >> $GITHUB_ENV
echo "VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" LCAmmoCheck/LCAmmoCheck.csproj)" >> $GITHUB_ENV
else
echo "Version did not change"
echo "STOP_WORKFLOW=true" >> $GITHUB_ENV
fi
- name: Set version from input
if: github.event_name == 'workflow_dispatch'
run: |
echo "STOP_WORKFLOW=false" >> $GITHUB_ENV
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Download artifacts
if: env.STOP_WORKFLOW == 'false'
run: |
gh run download --name DLL-Release --name Thunderstore-Release --dir ./publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: env.STOP_WORKFLOW == 'false'
uses: marvinpinto/action-automatic-releases@v1.2.1
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
draft: true
automatic_releases_tag: ${{ env.VERSION }}
files: |
./publish/DLL-Release/LCAmmoCheck.dll
./publish/Thunderstore-Release/LCAmmoCheck-${{ env.VERSION }}.zip