Release 3.2.221 #31
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 | |
env: | |
NUGET_URL: https://api.nuget.org/v3/index.json | |
INDEXING_TIMEOUT: 300 # seconds | |
DOTNET_SDK_VERSION: 8.0.201 | |
DOTNET_NOLOGO: true | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
ONEOF_REDUCED_PROJECT_PATH: ./src/OneOf.Reduced/OneOf.Reduced.csproj | |
STATERESULTS_PROJECT_PATH: ./src/StateResults/StateResults.csproj | |
STATERESULTS_GENERATOR_PROJECT_PATH: ./src/StateResults.Generator/StateResults.Generator.csproj | |
PUBLISH_DIR: publish | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build-and-set-flags: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_SDK_VERSION }} | |
- name: Build & Test | |
run: | | |
dotnet --info | |
dotnet restore | |
dotnet build -c Release | |
- name: Test | |
id: test | |
run: | | |
dotnet test --no-restore --no-build -c Release --verbosity normal | |
# Also, setting the PRERELEASE flag depending on the contents of the version file. | |
- name: Read Version | |
id: read_version | |
run: | | |
VERSION_CONTENT=$(cat ${{ github.workspace }}/src/StateResults/VERSION.g.txt) | |
echo "VERSION=$VERSION_CONTENT" | |
echo "VERSION=$VERSION_CONTENT" >> $GITHUB_OUTPUT | |
if [[ "$VERSION_CONTENT" == *-* ]]; then | |
echo "PRERELEASE=true" | |
echo "PRERELEASE=true" >> $GITHUB_OUTPUT | |
else | |
echo "PRERELEASE=false" | |
echo "PRERELEASE=false" >> $GITHUB_OUTPUT | |
fi | |
shell: bash | |
- name: Check VERSION and PRERELEASE variables | |
run: | | |
echo "VERSION=${{ steps.read_version.outputs.VERSION }}" | |
echo "PRERELEASE=${{ steps.read_version.outputs.PRERELEASE }}" | |
shell: sh | |
outputs: | |
VERSION: ${{ steps.read_version.outputs.VERSION }} | |
PRERELEASE: ${{ steps.read_version.outputs.PRERELEASE }} | |
publish-OneOf-Reduced: | |
needs: build-and-set-flags | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_SDK_VERSION }} | |
- name: Pack ${{ env.PACKAGE_NAME }} | |
run: | | |
dotnet pack ${{ env.ONEOF_REDUCED_PROJECT_PATH }} -c Release --include-symbols --include-source /p:PackageVersion=${{ needs.build-and-set-flags.outputs.VERSION }} -o . | |
- name: Upload Artifacts of BMTLab.OneOf.Reduced | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OneOf-Reduced-NuGetArtifacts | |
path: ./*.nupkg | |
- name: Check NuGet if ${{ env.PACKAGE_NAME }} is already pushed | |
id: check_pushed | |
run: | | |
chmod +x ${{ github.workspace }}/scripts/check-nuget-pkg-indexed.sh | |
PUSHED_RESULT=$(${{ github.workspace }}/scripts/check-nuget-pkg-indexed.sh -p "${{ env.PACKAGE_NAME }}" -v ${{ needs.build-and-set-flags.outputs.VERSION }} -a 1) | |
echo "PUSHED=$PUSHED_RESULT" >> $GITHUB_OUTPUT | |
shell: bash | |
continue-on-error: true | |
- name: Push NuGet for ${{ env.PACKAGE_NAME }} | |
if: ${{ steps.check_pushed.outputs.PUSHED != 'true' }} | |
run: dotnet nuget push ./*.nupkg --source ${{ env.NUGET_URL }} --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate | |
env: | |
PACKAGE_NAME: BMTLab.OneOf.Reduced | |
update-package-version: | |
runs-on: ubuntu-latest | |
needs: [build-and-set-flags, publish-OneOf-Reduced] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Necessary for correct work with history and tags | |
fetch-depth: 0 | |
- name: Update Directory.Packages.props | |
run: | | |
chmod +x ${{ github.workspace }}/scripts/rewrite-pkg-version.sh | |
${{ github.workspace }}/scripts/rewrite-pkg-version.sh -f "${{ github.workspace }}/Directory.Packages.props" -p "BMTLab.OneOf.Reduced" -v ${{ needs.build-and-set-flags.outputs.VERSION }} | |
shell: bash | |
- name: Commit updated version | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Actions" | |
git add Directory.Packages.props | |
git commit -m "[GitHub Actions] Release ${{ needs.build-and-set-flags.outputs.VERSION }}" | |
git push | |
- name: Push Git Tag | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git tag -a ${{ needs.build-and-set-flags.outputs.VERSION }} -m "Release ${{ needs.build-and-set-flags.outputs.VERSION }}" | |
git push origin ${{ needs.build-and-set-flags.outputs.VERSION }} | |
delay-for-nuget-indexing: | |
needs: [build-and-set-flags, publish-OneOf-Reduced] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Waiting for NuGet Package Indexing | |
id: wait_indexing | |
run: | | |
sleep ${{ env.INDEXING_TIMEOUT }} # seconds | |
chmod +x ${{ github.workspace }}/scripts/check-nuget-pkg-indexed.sh | |
PUSHED_RESULT=$(${{ github.workspace }}/scripts/check-nuget-pkg-indexed.sh -p "BMTLab.OneOf.Reduced" -v ${{ needs.build-and-set-flags.outputs.VERSION }} -a 12) | |
echo "PUSHED=$PUSHED_RESULT" >> $GITHUB_OUTPUT | |
shell: bash | |
outputs: | |
INDEXED: ${{ steps.wait_indexing.outputs.PUSHED }} | |
publish-StateResults: | |
needs: [ build-and-set-flags, update-package-version, delay-for-nuget-indexing] | |
runs-on: ubuntu-latest | |
if: ${{ needs.delay-for-nuget-indexing.outputs.INDEXED == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_SDK_VERSION }} | |
- name: Update Directory.Packages.props | |
run: | | |
chmod +x ${{ github.workspace }}/scripts/rewrite-pkg-version.sh | |
${{ github.workspace }}/scripts/rewrite-pkg-version.sh -f "${{ github.workspace }}/Directory.Packages.props" -p "BMTLab.OneOf.Reduced" -v ${{ needs.build-and-set-flags.outputs.VERSION }} | |
shell: bash | |
- name: Pack ${{ env.PACKAGE_NAME }} | |
run: | | |
dotnet pack ${{ env.STATERESULTS_PROJECT_PATH }} -c Release --include-symbols --include-source /p:PackageVersion=${{ needs.build-and-set-flags.outputs.VERSION }} -o . | |
- name: Upload Artifacts of ${{ env.PACKAGE_NAME }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: StateResults-NuGetArtifacts | |
path: ./*.nupkg | |
- name: Check NuGet if ${{ env.PACKAGE_NAME }} is already pushed | |
id: check_pushed | |
run: | | |
chmod +x ${{ github.workspace }}/scripts/check-nuget-pkg-indexed.sh | |
PUSHED_RESULT=$(${{ github.workspace }}/scripts/check-nuget-pkg-indexed.sh -p "${{ env.PACKAGE_NAME }}" -v ${{ needs.build-and-set-flags.outputs.VERSION }} -a 1) | |
echo "PUSHED=$PUSHED_RESULT" >> $GITHUB_OUTPUT | |
shell: bash | |
continue-on-error: true | |
- name: Push NuGet for ${{ env.PACKAGE_NAME }} | |
if: ${{ steps.check_pushed.outputs.PUSHED != 'true' }} | |
run: dotnet nuget push ./*.nupkg --source ${{ env.NUGET_URL }} --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate | |
env: | |
PACKAGE_NAME: BMTLab.StateResults | |
publish-StateResults-Generator: | |
needs: [ build-and-set-flags, update-package-version, delay-for-nuget-indexing] | |
runs-on: ubuntu-latest | |
if: ${{ needs.delay-for-nuget-indexing.outputs.INDEXED == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_SDK_VERSION }} | |
- name: Update Directory.Packages.props | |
run: | | |
chmod +x ${{ github.workspace }}/scripts/rewrite-pkg-version.sh | |
${{ github.workspace }}/scripts/rewrite-pkg-version.sh -f "${{ github.workspace }}/Directory.Packages.props" -p "BMTLab.OneOf.Reduced" -v ${{ needs.build-and-set-flags.outputs.VERSION }} | |
shell: bash | |
- name: Pack ${{ env.PACKAGE_NAME }} | |
run: | | |
dotnet pack ${{ env.STATERESULTS_GENERATOR_PROJECT_PATH }} -c Release --include-symbols --include-source /p:PackageVersion=${{ needs.build-and-set-flags.outputs.VERSION }} -o . | |
- name: Upload Artifacts of ${{ env.PACKAGE_NAME }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: StateResults-Generator-NuGetArtifacts | |
path: ./*.nupkg | |
- name: Check NuGet if ${{ env.PACKAGE_NAME }} is already pushed | |
id: check_pushed | |
run: | | |
chmod +x ${{ github.workspace }}/scripts/check-nuget-pkg-indexed.sh | |
PUSHED_RESULT=$(${{ github.workspace }}/scripts/check-nuget-pkg-indexed.sh -p "${{ env.PACKAGE_NAME }}" -v ${{ needs.build-and-set-flags.outputs.VERSION }} -a 1) | |
echo "PUSHED=$PUSHED_RESULT" >> $GITHUB_OUTPUT | |
shell: bash | |
continue-on-error: true | |
- name: Push NuGet for ${{ env.PACKAGE_NAME }} | |
if: ${{ steps.check_pushed.outputs.PUSHED != 'true' }} | |
run: dotnet nuget push ./*.nupkg --source ${{ env.NUGET_URL }} --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate | |
env: | |
PACKAGE_NAME: BMTLab.StateResults.Generator | |
create-GitHub-Release: | |
needs: [ build-and-set-flags, publish-OneOf-Reduced, publish-StateResults, publish-StateResults-Generator ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ env.PUBLISH_DIR }} | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.build-and-set-flags.outputs.VERSION }} | |
release_name: Release ${{ needs.build-and-set-flags.outputs.VERSION }} | |
prerelease: ${{ needs.build-and-set-flags.outputs.PRERELEASE }} | |
draft: false | |
- name: Upload Artifacts to Release | |
run: | | |
for file in ./${{ env.PUBLISH_DIR }}/*; do | |
echo "Uploading artifact: ${file}..." | |
curl \ | |
-X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: $(file -b --mime-type "${file}")" \ | |
--data-binary @"${file}" \ | |
"${{ steps.create_release.outputs.upload_url }}?name=$(basename "${file}")" | |
done | |
shell: bash | |
continue-on-error: true |