Skip to content

Merge pull request #98 from Lordfirespeed/actions-housekeeping #16

Merge pull request #98 from Lordfirespeed/actions-housekeeping

Merge pull request #98 from Lordfirespeed/actions-housekeeping #16

Workflow file for this run

name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
# Validate tag with proper regex since the check above is very limited.
validate-tag:
name: Validate tag semantic version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4
- name: Ensure triggering ref is a tag
id: tag
uses: devops-actions/[email protected]
- id: regex-match
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ steps.tag.outputs.tag }}
regex: '^([1-9][0-9]*|0)\.([1-9][0-9]*|0)\.([1-9][0-9]*|0)$'
- id: fail-fast
if: ${{ steps.regex-match.outputs.match == '' }}
uses: actions/github-script@v7
with:
script: core.setFailed('Tag is invalid')
platform-binary:
name: Build binaries for ${{ matrix.target }}
needs: validate-tag
if: github.event.base_ref == 'refs/heads/master'
runs-on: ${{ matrix.os }}
strategy:
matrix:
kind: ['linux', 'windows', 'macOS']
include:
- kind: linux
target: linux-x64
os: ubuntu-latest
- kind: windows
target: win-x64
os: windows-latest
- kind: macOS
target: osx-x64
os: macos-latest
steps:
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7'
- name: Install dependencies
run: dotnet restore
- name: Setup Cargo/Rust
uses: moonrepo/setup-rust@v1
- name: Build
shell: bash
run: |
release_name="tcli-${{ needs.validate-tag.outputs.tag }}-${{ matrix.target }}"
dotnet publish ThunderstoreCLI/ThunderstoreCLI.csproj -c Release -r "${{ matrix.target }}" --self-contained true -f net7.0 -o "${release_name}"
if [ "${{ matrix.target }}" == "win-x64" ]; then
7z a -tzip "${release_name}.zip" "./${release_name}"
else
tar czvf "${release_name}.tar.gz" "./${release_name}"
fi
rm -r ${release_name}
- name: Add build artifacts to draft GitHub release
uses: softprops/action-gh-release@v1
with:
files: "tcli*"
name: "Thunderstore CLI ${{ needs.validate-tag.outputs.tag }}"
body_path: ${{ github.workspace }}/.github/RELEASE_TEMPLATE.md
draft: true
prerelease: ${{ startsWith(needs.validate-tag.outputs.tag, '0.') }}
nupkg:
name: Build NuGet Package
needs: validate-tag
if: github.event.base_ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout ref that triggered workflow
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7'
- name: Install dependencies
run: dotnet restore
- name: Setup Cargo/Rust
uses: moonrepo/setup-rust@v1
- name: Build
shell: bash
run: dotnet pack ThunderstoreCLI/ThunderstoreCLI.csproj -c Release -o "." -p:EnableInstallers=false -p:PublishSelfContained=false -p:PublishSingleFile=false -p:PublishTrimmed=false -p:PublishReadyToRun=false
- name: Add build artifacts to draft GitHub release
uses: softprops/action-gh-release@v1
with:
files: "tcli*"
name: "Thunderstore CLI ${{ needs.validate-tag.outputs.tag }}"
body_path: ${{ github.workspace }}/.github/RELEASE_TEMPLATE.md
draft: true
prerelease: ${{ startsWith(needs.validate-tag.outputs.tag, '0.') }}