Publish #766
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
schedule: | |
- cron: '0 9 * * *' | |
workflow_dispatch: | |
release: | |
types: [published] | |
inputs: | |
is_release_event: | |
description: Should this be a release or a preview package | |
required: true | |
default: 'false' | |
jobs: | |
activity-short-circuit: | |
runs-on: ubuntu-latest | |
outputs: | |
same_sha: ${{ steps.check.outputs.same_sha }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get Activity Short Circuit | |
id: check | |
run: | | |
echo "Event name: ${{ github.event_name }}" | |
git branch -a | |
git fetch origin nightly:nightly | |
head_sha=$(git rev-parse --verify HEAD) | |
nightly_sha=$(git rev-parse --verify nightly) | |
if [[ "$head_sha" == "$nightly_sha" && ${{ github.event_name }} != "release" ]]; then | |
same_sha=true; | |
else | |
same_sha=false; | |
fi | |
echo "head_sha=$head_sha" | |
echo "nightly_sha=$nightly_sha" | |
echo "same_sha=${same_sha}" | |
echo "same_sha=${same_sha}" >> $GITHUB_OUTPUT | |
build-test: | |
needs: activity-short-circuit | |
if: needs.activity-short-circuit.outputs.same_sha == 'false' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
project: | |
- CSharpExt.UnitTests | |
- Noggog.Autofac | |
- Noggog.CSharpExt | |
- Noggog.CSharpExt.Json | |
- Noggog.CSharpExt.Windows | |
- Noggog.Testing | |
- Noggog.WPF | |
exclude: | |
- os: ubuntu-latest | |
project: Noggog.WPF | |
- os: macos-latest | |
project: Noggog.WPF | |
- os: ubuntu-latest | |
project: Noggog.CSharpExt.Windows | |
- os: macos-latest | |
project: Noggog.CSharpExt.Windows | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET 9 | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.* | |
- name: Install dependencies | |
run: | | |
dotnet clean -c Release && dotnet nuget locals all --clear | |
dotnet restore ${{ matrix.project }}/${{ matrix.project }}.csproj | |
- name: Build | |
run: dotnet build ${{ matrix.project }}/${{ matrix.project }}.csproj -c Release --no-restore | |
- name: Test | |
run: dotnet test ${{ matrix.project }}/${{ matrix.project }}.csproj -c Release --no-build | |
build-test-push: | |
needs: [build-test, activity-short-circuit] | |
if: needs.activity-short-circuit.outputs.same_sha == 'false' | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET 9 | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 9.0.* | |
- name: Install dependencies | |
run: | | |
dotnet clean Noggog.CSharpExt.sln -c Release && dotnet nuget locals all --clear | |
dotnet restore Noggog.CSharpExt.sln | |
- name: Build | |
run: dotnet build Noggog.CSharpExt.sln -c Release --no-restore /p:GeneratePackageOnBuild=false | |
- name: Pack | |
if: ${{ success() }} | |
run: | | |
dotnet pack Noggog.CSharpExt.sln -c Release --no-restore -o out --include-symbols -p:SymbolPackageFormat=snupkg | |
- name: Publish to Github | |
uses: svenstaro/upload-release-action@v2 | |
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }} | |
with: | |
file: "**/*.nupkg" | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.event.release.tag_name }} | |
file_glob: "true" | |
- name: Publish to Nuget.org | |
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
update-nightly: | |
needs: [build-test-push, activity-short-circuit] | |
if: needs.activity-short-circuit.outputs.same_sha == 'false' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Reset nightly to master | |
run: | | |
head_sha=$(git rev-parse --verify HEAD) | |
echo "head_sha=$head_sha" | |
git checkout nightly | |
git reset --hard $head_sha | |
git push |