Skip to content

Commit

Permalink
Merge pull request EXOK#90 from FujiAPI/workflow-improvements
Browse files Browse the repository at this point in the history
Reworking Github Actions Build And Publish Workflow
  • Loading branch information
jasminegamedev authored May 14, 2024
2 parents bdd2822 + 88cd57f commit f7c0594
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 247 deletions.
138 changes: 138 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
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 }}
124 changes: 0 additions & 124 deletions .github/workflows/build-beta.yml

This file was deleted.

120 changes: 0 additions & 120 deletions .github/workflows/build-stable.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Celeste64.Launcher/BuildProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace Celeste64.Launcher;
public partial class BuildProperties
{
[BuildProperty]
public static partial string ModVersion();
public static partial string BuildVersion();
}
Loading

0 comments on commit f7c0594

Please sign in to comment.