Skip to content

Merge pull request #35 from BUTR/dependabot/github_actions/actions/do… #60

Merge pull request #35 from BUTR/dependabot/github_actions/actions/do…

Merge pull request #35 from BUTR/dependabot/github_actions/actions/do… #60

Workflow file for this run

name: Build and Publish
on:
push:
tags:
- '*'
branches: master
paths:
- '.github/workflows/publish.yml'
- '**.cs'
- '**.csproj'
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build-and-publish-as-tool:
name: Build and Publish as Tool
runs-on: ubuntu-latest
steps:
- name: Setup
uses: butr/actions-common-setup@v2.1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
- name: Pack
run: dotnet pack src/Bannerlord.LocalizationParser/Bannerlord.LocalizationParser.csproj -c Release -o ./packages
shell: pwsh
- name: Push to NuGet
run: dotnet nuget push "./packages/*.nupkg" -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json
shell: pwsh
- name: Push to GPR
run: |
for f in ./packages/*.nupkg
do
curl -vX PUT -u "vslee:${{secrets.GITHUB_TOKEN}}" -F package=@$f https://nuget.pkg.github.com/BUTR/
done
shell: bash
build-and-publish-executables-release:
name: Build and Publish Executables - Create Github Release
if: contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Output Release URL File
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- name: Save Release URL File for publish
uses: actions/upload-artifact@v4
with:
name: release_url
path: release_url.txt
build-and-publish-executables:
name: Build and Publish Executables
if: contains(github.ref, 'tags/v')
needs: [build-and-publish-executables-release]
runs-on: ubuntu-latest
strategy:
matrix:
platform: ["win-x64", "win-x86", "linux-x64", "win-arm", "linux-arm"]
self_contained: ["true", "false"]
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Load Release URL File from release job
uses: actions/download-artifact@v4
with:
name: release_url
- name: Get Release File Name & Upload URL
id: get_release_info
run: |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} # RepositoryName-v1.0.0
value=`cat release_url/release_url.txt`
echo ::set-output name=upload_url::$value
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
- name: Setup .NET Core
uses: actions/setup-dotnet@master
with:
dotnet-version: 5.0.x
- name: Setup BUTR GPR
uses: actions/setup-dotnet@master
with:
source-url: https://nuget.pkg.github.com/BUTR/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Publish
run: >-
dotnet publish src/Bannerlord.LocalizationParser/Bannerlord.LocalizationParser.csproj `
-c Release `
-o ./output `
-r ${{matrix.platform}} `
--self-contained ${{matrix.self_contained}} `
-p:PublishReadyToRun=false `
-p:PublishReadyToRunShowWarnings=false `
-p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true `
-p:DebugType=embedded;
shell: pwsh
- uses: papeloto/action-zip@v1
with:
files: ./output
dest: output.zip
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ./output.zip
# fake ternary
asset_name: ${{ steps.get_release_info.outputs.file_name }}${{ matrix.self_contained != 'false' && '-self-contained' || '' }}-${{ matrix.platform }}.zip
asset_content_type: application/zip