Skip to content

Publish

Publish #21

Workflow file for this run

# This workflow will publish the project
name: Publish
on:
workflow_dispatch:
inputs:
config-file:
type: string
default: "./publish/config.json"
target-os:
type: choice
default: all
options:
- windows
- linux
- macos
- all
target-runtime:
type: choice
default: all
options:
- x86
- x64
- arm
- arm64
- all
release:
types: [published]
env:
dotnet-version: 9.x
default-config-file: "./publish/config.json"
default-target-os: all
default-target-runtime: all
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.publish-config-parser.outputs.profiles }}
status: ${{ steps.checker.outputs.status }}
project-file: ${{ steps.publish-config-parser.outputs.project-file }}
output-name: ${{ steps.publish-config-parser.outputs.output-name }}
target-os: ${{ steps.inputs.outputs.target-os }}
target-runtime: ${{ steps.inputs.outputs.target-runtime }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: recursive
- id: inputs
shell: bash
run: |
config_file='${{ github.event.inputs.config-file }}'
target_os='${{ github.event.inputs.target-os }}'
target_runtime='${{ github.event.inputs.target-runtime }}'
echo "config-file=${config_file:=${{ env.default-config-file }}}" >> $GITHUB_OUTPUT
echo "target-os=${target_os:=${{ env.default-target-os }}}" >> $GITHUB_OUTPUT
echo "target-runtime=${target_runtime:=${{ env.default-target-runtime }}}" >> $GITHUB_OUTPUT
- name: Parse configuration "${{ github.event.inputs.config-file }}"
id: publish-config-parser
uses: ./.github/actions/publish-config-parser
with:
config-file: ${{ env.config-file }}
tags: "${{ env.target-os }},${{ env.target-runtime }}"
env:
config-file: ${{ steps.inputs.outputs.config-file }}
target-os: ${{ steps.inputs.outputs.target-os }}
target-runtime: ${{ steps.inputs.outputs.target-runtime }}
- name: Check profiles
id: checker
run: |
profiles='${{ steps.publish-config-parser.outputs.profiles }}'
length=$( echo $profiles | jq '.include | length' )
if(( $length > 0 )); then
echo "status=success" >> $GITHUB_OUTPUT
else
echo "status=failure" >> $GITHUB_OUTPUT
echo "No suitable publish profile found"
fi
publish:
name: Publish
needs: prepare
if: needs.prepare.outputs.status == 'success'
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJson(needs.prepare.outputs.matrix)}}
outputs:
version-full: "${{ steps.version-number.outputs.preset-suffix-githash }}"
version-short: "${{ steps.version-number.outputs.preset-suffix }}"
env:
output-name: ${{ needs.prepare.outputs.output-name }}
project-file: ${{ needs.prepare.outputs.project-file }}
configuration: ${{ matrix.configuration }}
framework: ${{ matrix.framework }}
runtime: ${{ matrix.runtime }}
publish-options: ${{ matrix.options }}
output-path: '.publish/output/bin/${{ matrix.configuration }}/${{ matrix.framework }}/${{ matrix.runtime }}'
steps:
- name: Support longpaths
if: ${{ matrix.os == 'windows-latest'}}
run: git config --system core.longpaths true
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: recursive
- name: Install .NET
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
with:
dotnet-version: ${{ env.dotnet-version }}
- id: version-number
uses: finebits/github-actions/toolset/find-out-version@4a126d80a11c5fdc83ce884d3d23dffb30bc4495 # v2.0.0
- uses: finebits/github-actions/toolset/file/replace-text@4a126d80a11c5fdc83ce884d3d23dffb30bc4495 # v2.0.0
with:
file: ./src/Eppie.CLI/Eppie.CLI/Options/AuthorizationOptions.cs
placeholder: '\"<Gmail-ClientId>\"'
value: "${{ secrets.GMAIL_CLIENT_ID }}"
- uses: finebits/github-actions/toolset/file/replace-text@4a126d80a11c5fdc83ce884d3d23dffb30bc4495 # v2.0.0
with:
file: ./src/Eppie.CLI/Eppie.CLI/Options/AuthorizationOptions.cs
placeholder: '\"<Gmail-ClientSecret>\"'
value: "${{ secrets.GMAIL_CLIENT_SECRET }}"
- uses: finebits/github-actions/toolset/file/replace-text@4a126d80a11c5fdc83ce884d3d23dffb30bc4495 # v2.0.0
with:
file: ./src/Eppie.CLI/Eppie.CLI/Options/AuthorizationOptions.cs
placeholder: '\"<Outlook-ClientId>\"'
value: "${{ secrets.OUTLOOK_CLIENT_ID }}"
- name: Publish ${{ env.output-name }} [${{ env.version-short }}]
run: |
dotnet publish "${{ env.project-file }}" --output "${{ env.output-path }}" --configuration "${{ env.configuration }}" --framework "${{ env.framework }}" --runtime "${{ env.runtime }}" --property:Version="${{ env.version-full }}" ${{ env.publish-options }}
env:
version-full: "${{ steps.version-number.outputs.preset-suffix-githash }}"
version-short: "${{ steps.version-number.outputs.preset-suffix }}"
- name: Check AZURE secrets
if: ${{ matrix.os == 'windows-latest' }}
id: check-azure-secrets
shell: bash
run: |
exist=true
if [ "${{ secrets.AZURE_TENANT_ID }}" == "" ]; then
echo "::warning::'secrets.AZURE_TENANT_ID' is empty"
exist=false
fi
if [ "${{ secrets.AZURE_CLIENT_ID }}" == "" ]; then
echo "::warning::'secrets.AZURE_CLIENT_ID' is empty"
exist=false
fi
if [ "${{ secrets.AZURE_CLIENT_SECRET }}" == "" ]; then
echo "::warning::'secrets.AZURE_CLIENT_SECRET' is empty"
exist=false
fi
if [ "${{ secrets.TRUSTED_SIGNING_ACCOUNT_NAME }}" == "" ]; then
echo "::warning::'secrets.TRUSTED_SIGNING_ACCOUNT_NAME' is empty"
exist=false
fi
if [ "${{ secrets.CERTIFICATE_PROFILE_NAME }}" == "" ]; then
echo "::warning::'secrets.CERTIFICATE_PROFILE_NAME' is empty"
exist=false
fi
echo "secrets-exist=$exist" >> $GITHUB_OUTPUT
- name: Sign files with Trusted Signing
if: ${{ matrix.os == 'windows-latest' && steps.check-azure-secrets.outputs.secrets-exist == 'true' }}
uses: azure/trusted-signing-action@07c81171dd46a04e1b9f382b6c693815828bbbf7 # v0.5.0
with:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
endpoint: https://neu.codesigning.azure.net/
trusted-signing-account-name: ${{ secrets.TRUSTED_SIGNING_ACCOUNT_NAME }}
certificate-profile-name: ${{ secrets.CERTIFICATE_PROFILE_NAME }}
files-folder: ${{ env.output-path }}
files-folder-filter: exe
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
- name: Upload artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: "${{ env.artifact-name }}-${{ env.runtime }} [${{ env.version-short }}]"
path: "${{ env.output-path }}"
env:
artifact-name: "${{ env.output-name }}"
version-short: "${{ steps.version-number.outputs.preset-suffix }}"
appimage-package:
name: Pack AppImage
needs: [ prepare, publish ]
runs-on: ubuntu-latest
if: ${{ needs.prepare.outputs.target-os == 'all' || needs.prepare.outputs.target-os == 'linux' }}
strategy:
matrix:
include:
- target-runtime: 'x64'
artifact_pattern: '*linux-x64*'
appimage-arch: x86_64
- target-runtime: 'arm64'
artifact_pattern: '*linux-arm64*'
appimage-arch: aarch64
- target-runtime: 'arm'
artifact_pattern: '*linux-arm*'
appimage-arch: armhf
env:
artifacts-root: './.artifacts'
output-path: './.publish/output/packages'
package-app-dir: './packages/appimage-package/AppDir'
prepare-script: './packages/appimage-package/prepare-AppDir.sh'
steps:
- name: Check runtime
run: |
go_on=${{ needs.prepare.outputs.target-runtime == 'all' || needs.prepare.outputs.target-runtime == matrix.target-runtime }}
echo "GITHUB_ACTION_GO_PACK=$go_on" >> $GITHUB_ENV
- name: Checkout
if: ${{ env.GITHUB_ACTION_GO_PACK == 'true' }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: recursive
- name: Setup appimagetool
if: ${{ env.GITHUB_ACTION_GO_PACK == 'true' }}
uses: finebits/github-actions/package/appimage/setup-appimagetool@4a126d80a11c5fdc83ce884d3d23dffb30bc4495 # v2.0.0
- name: Download ${{ matrix.artifact_pattern }} Artifacts
if: ${{ env.GITHUB_ACTION_GO_PACK == 'true' }}
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: "${{ env.artifacts-root }}"
pattern: "${{ matrix.artifact_pattern }}"
- name: Prepare Package
if: ${{ env.GITHUB_ACTION_GO_PACK == 'true' }}
shell: bash
run: |
item=$(find "${{ env.artifacts-root }}" -name "${{ matrix.artifact_pattern }}" | head -n 1)
if [ ! -d "$item" ] ; then
echo "::error::Artifact '${{ matrix.artifact_pattern }}' not found."
exit 1
fi
echo "$(bash "${{ env.prepare-script }}" "$item")"
mkdir -p "${{ env.output-path }}"
- name: Pack appimagetool
if: ${{ env.GITHUB_ACTION_GO_PACK == 'true' }}
uses: finebits/github-actions/package/appimage/pack@4a126d80a11c5fdc83ce884d3d23dffb30bc4495 # v2.0.0
with:
package-runtime: ${{ matrix.appimage-arch }}
package-app-dir: "${{ env.package-app-dir }}"
package-output-dir: "${{ env.output-path }}"
- name: Read name
if: ${{ env.GITHUB_ACTION_GO_PACK == 'true' }}
id: package-name
shell: bash
run: |
item=$(find "${{ env.output-path }}" -name "*.AppImage" | head -n 1)
if [ ! -f "$item" ] ; then
echo "::error::AppImage Pacakge '$item' not found."
exit 1
fi
item_name="${item##*/}"
echo "name=$item_name" >> $GITHUB_OUTPUT
- name: Upload artifacts
if: ${{ env.GITHUB_ACTION_GO_PACK == 'true' }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: "${{ env.artifact-name }} [${{ env.version-short }}]"
path: "${{ env.output-path }}"
env:
artifact-name: "${{ steps.package-name.outputs.name }}"
version-short: "${{ needs.publish.outputs.version-short }}"
upload-assets:
name: Upload Assets
if: github.event_name == 'release'
needs: [ publish, appimage-package ]
runs-on: ubuntu-latest
permissions:
contents: write
env:
artifacts-root: './.artifacts'
assets-root: './.assets'
steps:
- name: Download All Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: "${{ env.artifacts-root }}"
- name: Prepare Assets
shell: bash
run: |
asset_root="${{ env.assets-root }}"
mkdir -p "${asset_root}"
artifact_pattern="${{ env.artifacts-root }}/*"
for item in $artifact_pattern ; do
if [ -d "$item" ] ; then
item_name="${item##*/}"
# remove version
asset_name="${item_name% [*}"
if [[ "$asset_name" == *"-osx-"* || "$asset_name" == *"-linux-"* ]]; then
tar -czf "$asset_root/${asset_name}.tar.gz" -C "$item" . && echo "Archiving of the asset '$asset_name' has been completed successfully." || echo "::warning::Failed to archive asset '$asset_name'"
elif [[ "$asset_name" == *"-win-"* ]]; then
zip -rjq "$asset_root/${asset_name}.zip" "$item" && echo "Archiving of the asset '$asset_name' has been completed successfully." || echo "::warning::Failed to archive asset '$asset_name'"
elif [[ "$asset_name" == *".AppImage" ]]; then
file=$(find "$item" -name "*.AppImage" | head -n 1)
echo "package: ${file}"
cp "${file}" "$asset_root" && echo "Copying of the asset '$asset_name' has been completed successfully." || echo "::warning::Failed to copy asset '$asset_name'"
else
echo "::warning::Unknown asset type: '$asset_name'"
fi
fi
done
- name: Upload All Assets
uses: finebits/github-actions/toolset/github/upload-release-asset@4a126d80a11c5fdc83ce884d3d23dffb30bc4495 # v2.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.release.tag_name }}
path: "${{ env.assets-root }}/*"