PdfPig/.github/workflows/nightly_release.yml

73 lines
2.4 KiB
YAML

name: Nightly Release
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
tests:
uses: ./.github/workflows/run_integration_tests.yml
check_publish_needed:
runs-on: ubuntu-latest
name: Check if this commit has already been published
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- uses: actions/checkout@master
- name: Fetch nightly-latest tag
run: |
git fetch origin nightly-latest || true
- id: check
run: |
latest_commit=$(git rev-parse origin/nightly-latest || echo "")
echo "Latest published commit: $latest_commit"
if [ "$latest_commit" = "${{ github.sha }}" ]; then
echo "No new commit since last publish."
echo "should_run=false" >> $GITHUB_OUTPUT
else
echo "New commit detected."
echo "should_run=true" >> $GITHUB_OUTPUT
fi
build_and_publish_nightly:
needs: [check_publish_needed, tests]
if: ${{ needs.check_publish_needed.outputs.should_run != 'false' }}
runs-on: windows-2022
name: build_and_publish_nightly
steps:
- uses: actions/checkout@master
- name: Set up dotnet core
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
2.1.x
6.0.x
8.0.x
9.0.x
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
- name: Write nightly version to projects
run: |
$newVer = .\tools\generate-nightly-version.ps1; .\tools\set-version.ps1 $newVer
- name: Restore packages
run: dotnet restore tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj
- name: Build package
run: dotnet pack -c Release -o package tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
- name: Publish Nuget to GitHub registry
run: dotnet nuget push **/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag latest nightly commit
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag -f nightly-latest ${{ github.sha }}
git push origin nightly-latest --force