Skip to content

Build and publish branch #3

Build and publish branch

Build and publish branch #3

name: Build and publish branch
on:
workflow_dispatch:
inputs:
tag:
required: true
description: Tag for the release that is generated. This must use semvar like `X.Y.Z` for stable branches or `beta-X.Y.Z-*` for beta branches
is-beta:
type: boolean
default: false
description: Is this a beta release?
make-latest:
type: boolean
default: true
description: Should the generated release be flagged as the latest release?
prerelease:
type: boolean
default: false
description: Should the generated release be flagged as a prerelease?
draft:
type: boolean
default: true
description: Should the generated release be flagged as a draft?
permissions:
contents: write
defaults:
run:
shell: bash
jobs:
validate_inputs:
name: Validate Inputs
runs-on: ubuntu-latest
steps:
- name: Validate Stable Tag
if: ${{ ! inputs.is-beta }}
run: |
if [[ !(${{ inputs.tag }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$) ]]; then
echo "Error: Tag is not in a valid semvar format. Stable releases should follow the format of 'X.Y.Z'"
exit 1
fi
- name: Validate Beta Tag
if: ${{ inputs.is-beta }}
run: |
if [[ !(${{ inputs.tag }} =~ ^beta\-[0-9]+\.[0-9]+\.[0-9]+\-*) ]]; then
echo "Error: Tag is formatted correctly. Beta releases should follow the format of 'beta-X.Y.Z-*'"
exit 1
fi
create_release:
name: Create Release
needs: validate_inputs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-tags: true
- name: Create release
uses: ncipollo/release-action@v1
with:
tag: ${{ inputs.tag }}
commit: "${{ github.sha }}"
body: |
# Instructions:
- Download and extract the zip file below according to your computer
- Run the Celeste64-Fuji application from the extracted files
# Requirements:
- **Windows:** 10 or later, x64
- **Linux:** [Distro support list](https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md), x64 or arm
- **macOS:** Monterey or later, x64 or arm Intel-based or Apple Silicon with Rosetta
allowUpdates: true
name: "Fuji ${{ inputs.tag }} "
prerelease: ${{ inputs.prerelease }}
makeLatest: ${{ inputs.make-latest }}
draft: ${{ inputs.draft }}
build:
name: Build Artifacts
needs: create_release
strategy:
matrix:
include:
- { platform: macos-latest, rid: osx-arm64 }
- { platform: macos-latest, rid: osx-x64 }
- { platform: ubuntu-latest, rid: linux-arm }
- { platform: ubuntu-latest, rid: linux-arm64 }
- { platform: ubuntu-latest, rid: linux-x64 }
- { platform: windows-latest, rid: win-x64 }
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
with:
fetch-tags: true
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Build
run: |
dotnet publish Celeste64.Launcher/Celeste64.Launcher.csproj -c Release -r ${{ matrix.rid }} -p:ImportByWildcardBeforeSolution=false "-p:EmbeddedBuildProperty=BuildVersion=${{ inputs.tag }}" -o build
cp -r Content Mods build
- name: Compress
if: runner.os == 'Windows'
shell: pwsh
run: |
cd build && Compress-Archive * ../Celeste64-Fuji-${{ matrix.rid }}-${{ inputs.tag }}.zip
- name: Compress
if: runner.os != 'Windows'
run: |
cd build && zip -r ../Celeste64-Fuji-${{ matrix.rid }}-${{ inputs.tag }}.zip *
- name: Upload artifact to release
uses: ncipollo/release-action@v1
with:
artifacts: Celeste64-Fuji-${{ matrix.rid }}-${{ inputs.tag }}.zip
commit: "${{ github.sha }}"
tag: ${{ inputs.tag }}
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
draft: ${{ inputs.draft }}
- name: Cancel release
if: ${{ failure() }}
run: gh release delete --cleanup-tag -y ${{ inputs.tag }}
env:
GH_TOKEN: ${{ github.token }}