Skip to content

Publish

Publish #29

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
sign:
description: 'Code Sign'
type: boolean
required: false
default: true
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
GITHUB_ACTIONS: true
jobs:
build:
runs-on: ubuntu-latest
outputs:
SemVer: ${{ steps.gitversion.outputs.SemVer }}
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: 5.x
- name: Determine Version
uses: gittools/actions/gitversion/[email protected]
id: gitversion
- name: Display GitVersion outputs
run: |
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
global-json-file: global.json
- name: Build and Publish Package
run: |
publish() {
output_path="./Artifacts/input_display_$1_${{ steps.gitversion.outputs.SemVer }}"
dotnet publish src/InputDisplay \
--configuration Release --self-contained \
--output "$output_path" \
-r $1 -p:DebugType=None -p:DebugSymbols=false \
-p:Version='${{ steps.gitversion.outputs.SemVer }}'
if [[ "$1" == *"win"* ]]; then
find "$output_path" -name "*.sh" -delete
else
find "$output_path" -name "*.cmd" -delete
fi
}
publish "win-x64"
publish "linux-x64"
publish "osx-x64"
- name: Zip artifacts
run: cd ./Artifacts; zip -r ../artifacts.zip *
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: app
path: artifacts.zip
sign:
runs-on: windows-latest
needs: build
if: github.event.inputs.sign == 'true' && github.ref == 'refs/heads/master' && needs.build.outputs.CommitsSinceVersionSource > 0
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: app
- name: Unzip artifacts
run: Expand-Archive -Path .\artifacts.zip -DestinationPath .\Artifacts
- name: Sign exe
uses: markeytos/[email protected]
with:
certificate: '${{ secrets.CERTIFICATE }}'
password: '${{ secrets.PASSWORD }}'
certificatesha1: '${{ secrets.CERTIFICATESHA1 }}'
folder: .\Artifacts\input_display_win-x64_${{ needs.build.outputs.SemVer }}
timestampUrl: 'http://timestamp.digicert.com'
recursive: true
- name: Zip artifacts
run: |
Remove-Item ./artifacts.zip
Compress-Archive -Path ./Artifacts/* -Destination artifacts.zip
- name: Upload artifact for deployment
uses: actions/upload-artifact@v3
with:
name: app
path: artifacts.zip
release:
runs-on: ubuntu-latest
needs: [ build, sign ]
if: | #Only release if there has been a commit/version change
always()
&& github.ref == 'refs/heads/master' && needs.build.outputs.CommitsSinceVersionSource > 0
&& needs.build.result == 'success'
&& (needs.sign.result == 'success' || needs.sign.result == 'skipped')
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: app
- name: Unzip Artifacts
run: unzip artifacts.zip -d ./Artifacts
- name: Zip Platform Artifacts
run: |
cd Artifacts
for subdir in */; do
dirname=$(basename "$subdir")
cd "$subdir"
zip -r "../$dirname.zip" *
cd ..
done
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.build.outputs.SemVer }}
name: Release ${{ needs.build.outputs.SemVer }}
artifacts: "./Artifacts/*.zip"
token: ${{ secrets.GITHUB_TOKEN }}