Skip to content

Publish Outbox bundle #2

Publish Outbox bundle

Publish Outbox bundle #2

# Copyright 2020 Energinet DataHub A/S
#
# Licensed under the Apache License, Version 2.0 (the "License2");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Publish Outbox bundle
on:
# Build, test, pack and publish release packages
# Only executed if (*.)Outbox packages content or build scripts has changed; not if solution file, documentation or tests has changed
push:
branches:
- main
paths:
- source/Outbox/source/Outbox/**
- source/Outbox/source/Outbox.Abstractions/**
- .github/workflows/outbox-bundle-publish.yml
# Build, test, pack
# Executed if Outbox folder or build scripts has changed; including if documentation or tests has changed
workflow_call: {}
# Build, test, pack and publish prerelease packages
# Executed if manually triggered
workflow_dispatch: {}
env:
# Conditions
PUSH_PACKAGES: ${{ github.event_name != 'pull_request' }}
jobs:
build_and_publish:
runs-on: windows-2022
name: Publish bundle to NuGet.org
environment: AzureAuth
# We need to have permissions here to be able to support manually triggering this workflow for releasing a pre-release.
permissions:
id-token: write # Needed by 'dotnet-solution-build-and-test' to login to Azure
contents: read # Needed by https://github.com/EnricoMi/publish-unit-test-result-action
issues: read # Needed by https://github.com/EnricoMi/publish-unit-test-result-action
checks: write # Needed by https://github.com/EnricoMi/publish-unit-test-result-action
pull-requests: write # Needed by https://github.com/EnricoMi/publish-unit-test-result-action
steps:
- name: Checkout repository
uses: Energinet-DataHub/.github/.github/actions/nuget-checkout-repository@v13
- name: Setup dotnet and tools
uses: Energinet-DataHub/.github/.github/actions/dotnet-setup-and-tools@v13
with:
use_azure_functions_tools: "true"
azurite_version: 3.31.0
- name: Build and test solution
uses: Energinet-DataHub/.github/.github/actions/dotnet-solution-build-and-test@v13
with:
solution_file_path: ./source/Outbox/Outbox.sln
publish_test_report: "true"
- name: Pack Outbox project
uses: Energinet-DataHub/.github/.github/actions/nuget-project-pack@v13
with:
project_path: ./source/Outbox/source/Outbox/Outbox.csproj
- name: Pack Outbox.Abstractions project
uses: Energinet-DataHub/.github/.github/actions/nuget-project-pack@v13
with:
project_path: ./source/Outbox/source/Outbox.Abstractions/Outbox.Abstractions.csproj
- name: Package content or build has changed
id: changed-content
uses: tj-actions/changed-files@v41
with:
files: |
source/Outbox/source/Outbox/**/*.*
source/Outbox/source/Outbox.Abstractions/**/*.*
.github/workflows/outbox-bundle-publish.yml
- name: Assert versions of NuGet packages and push them to NuGet.org
uses: Energinet-DataHub/.github/.github/actions/nuget-packages-assert-and-push@v13
with:
push_packages: ${{ env.PUSH_PACKAGES }}
content_changed: ${{ steps.changed-content.outputs.any_changed }}
nuget_token: ${{ secrets.nuget_token }}
nupkg_recurse_path: source/Outbox/source
#
# Branch policy status check
#
allow_merge:
runs-on: ubuntu-latest
needs: [build_and_publish]
if: |
always()
steps:
- name: Verify if merge is allowed
run: |
echo "${{ toJSON(needs) }}"
if [[ ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} = true ]]; then
echo "Failed"
exit 1
fi