Create pre-release for branch builds on manual workflow run #26
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: Continuous Delivery | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
force-release: | |
type: boolean | |
description: Force tag & release even when the source branch is not main | |
jobs: | |
continuous-delivery: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: 7.0.x | |
- name: Build & Test | |
run: ./Build/build-and-test.ps1 | |
shell: pwsh | |
- name: Upload Coverage Badge | |
if: github.event_name != 'pull_request' && matrix.os == 'windows-latest' | |
uses: exuanbo/actions-deploy-gist@v1 | |
with: | |
token: ${{ secrets.CODE_COVERAGE_AUTH_TOKEN }} | |
gist_id: 527882e89a938dc78f61a08c300edec4 | |
gist_description: "code-coverage-${{ github.ref_name }}" | |
gist_file_name: fmsync-code-coverage-${{ github.ref_name }}.svg | |
file_path: tests/TestResults/badge_shieldsio_linecoverage_green.svg | |
- name: Build Windows Installer | |
if: matrix.os == 'windows-latest' | |
run: ./Build/build-windows-installer.ps1 | |
shell: pwsh | |
- name: Check if PR Exists | |
id: prcheck | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
$prs = $(gh pr list ` | |
--repo "$env:GITHUB_REPOSITORY" ` | |
--json baseRefName,headRefName ` | |
--jq ' | |
map(select(.baseRefName == \"main\" and .headRefName == \"${{ github.ref_name }}\")) | |
| length | |
') | |
$exists = ($prs -gt 0) | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "pull_request_exists=$exists" | |
shell: pwsh | |
- name: Check for Release Requirement | |
id: release-check | |
run: | | |
$needs-release = (${{ github.ref_name }} -eq 'main') -or (${{ github.event.inputs.force-release }} -e 'true') | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "needs-release=$needs-release" | |
shell: pwsh | |
- name: Tag With SemVer | |
id: tag | |
if: github.ref_name == 'main' | |
run: ./Build/tag-with-semver.ps1 | |
shell: pwsh | |
- name: Debug Output | |
run: | | |
Write-Output "github.ref_name:${{ github.ref_name }}" | |
Write-Output "github.event_name:${{ github.event_name }}" | |
Write-Output "github.ref:${{ github.ref }}" | |
Write-Output "env.GitVersion_SemVer:${{ env.GitVersion_SemVer }}" | |
Write-Output "steps.prcheck.outputs.pull_request_exists:${{ steps.prcheck.outputs.pull_request_exists }}" | |
Write-Output "steps.release-check.outputs.needs-release:${{ steps.release-check.outputs.needs-release }}" | |
shell: pwsh | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: github.ref_name == 'main' || (github.event_name == 'push' && contains(github.ref, 'refs/tags/')) | |
with: | |
tag_name: ${{ env.GitVersion_SemVer }} | |
generate_release_notes: true | |
prerelease: ${{ github.ref_name != 'main' }} | |
files: ./Installer/Elzik.FmSync.WindowsInstaller/bin/x64/Release/en-US/Elzik.FmSync.WindowsInstaller.msi |