Publish Release #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 artifact | |
if: env.STOP_WORKFLOW == 'false' | |
uses: actions/download-artifact@v4 | |
with: | |
# DLL-Release and Thunderstore-Release are the artifact names from the build workflow | |
pattern: "*-Release" | |
merge-multiple: true | |
path: ./publish | |
- 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/LCAmmoCheck.dll | |
./publish/LCAmmoCheck-*.zip |