Publish Release #6
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 Release | |
env: | |
DOTNET_VERSION: "6.0.x" | |
on: | |
workflow_dispatch: | |
inputs: | |
vendor_version: | |
type: string | |
description: "Vendor Version (semver) for the release -- what will be visible." | |
default: "1.0.0" | |
required: true | |
permissions: | |
contents: write | |
jobs: | |
create_release_tag: | |
name: "Create release tag" | |
environment: "Production" | |
runs-on: ubuntu-latest | |
env: | |
PL_VENDOR_VERSION: ${{ github.event.inputs.vendor_version || '1.0.0' }} | |
outputs: | |
is_prerelase: ${{ steps.versioning.outputs.is-prerelease }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Determine release version | |
id: versioning | |
uses: Fresa/trunk-based-release-versioning@v0 | |
- name: Convert commit logs to JSON | |
id: convert-commit-logs | |
uses: mikefarah/[email protected] | |
with: | |
cmd: yq ea -o=json 'select(. != null) | [.]' "$(echo "${{ steps.versioning.outputs.commit-logs-path }}" | sed "s|^${{ github.workspace }}/||")" | tee commit_logs.json | |
- name: Generate release notes | |
id: release_notes | |
uses: Fresa/release-notes-generator@v2 | |
with: | |
version: ${{ env.PL_VENDOR_VERSION }} | |
last_release_ref: ${{ steps.versioning.outputs.last-release-ref }} | |
release_ref: ${{ steps.versioning.outputs.release-ref }} | |
path_to_commits: ./commit_logs.json | |
- name: Create release and tags | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: "v${{ env.PL_VENDOR_VERSION }}" | |
name: "v${{ env.PL_VENDOR_VERSION }}" | |
body: ${{ steps.release_notes.outputs.release_notes }} | |
prerelease: ${{ steps.versioning.outputs.is-prerelease }} | |
draft: false | |
files: appsettings.json | |
fail_on_unmatched_files: true | |
release: | |
name: "Release apps" | |
environment: "Production" | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [ubuntu-latest, windows-2022] | |
runs-on: ${{ matrix.platform }} | |
needs: create_release_tag | |
env: | |
PL_VENDOR_VERSION: ${{ github.event.inputs.vendor_version || '1.0.0' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Build release | |
run: dotnet build --configuration Release | |
- name: Publish application | |
if: matrix.platform == 'windows-2022' | |
run: | | |
dotnet publish \ | |
-c Release \ | |
-r win-x64 \ | |
-p:PublishReadyToRun=true \ | |
-p:PublishSingleFile=true \ | |
-p:Version=${{ env.PL_VENDOR_VERSION }} \ | |
-p:AssemblyVersion=${{ env.PL_VENDOR_VERSION }}.${{ github.run_id }} \ | |
--self-contained true | |
- name: Publish application | |
if: matrix.platform == 'ubuntu-latest' | |
run: | | |
dotnet publish \ | |
-c Release \ | |
-r linux-x64 \ | |
-p:PublishReadyToRun=true \ | |
-p:PublishSingleFile=true \ | |
-p:Version=${{ env.PL_VENDOR_VERSION }} \ | |
-p:AssemblyVersion=${{ env.PL_VENDOR_VERSION }}.${{ github.run_id }} \ | |
--self-contained true | |
- name: Upload windows executable | |
if: matrix.platform == 'windows-2022' | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: "v${{ env.PL_VENDOR_VERSION }}" | |
file: bin/Release/net6.0/win-x64/publish/docker-hosts-writer.exe | |
asset_name: docker-host-writer-${{ env.PL_VENDOR_VERSION }}-windows.exe | |
prerelease: ${{ needs.create_release_tag.outputs.is_prerelase }} | |
- name: Upload linux executable | |
if: matrix.platform == 'ubuntu-latest' | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: "v${{ env.PL_VENDOR_VERSION }}" | |
file: bin/Release/net6.0/linux-x64/publish/docker-hosts-writer | |
asset_name: docker-host-writer-${{ env.PL_VENDOR_VERSION }}-linux | |
prerelease: ${{ needs.create_release_tag.outputs.is_prerelase }} |