Release v0.1.3-alpha #7
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
# 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: 8.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 }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
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)}} | |
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/${{ matrix.configuration }}/${{ matrix.framework }}/${{ matrix.runtime }}' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.dotnet-version }} | |
- id: version-number | |
uses: finebits/github-actions/version-number@v1 | |
- uses: finebits/github-actions/pre-build/replace@v1 | |
with: | |
file: ./src/Eppie.CLI/Eppie.CLI/Options/AuthorizationOptions.cs | |
placeholder: '\"<Gmail-ClientId>\"' | |
value: "${{ secrets.GMAIL_CLIENT_ID }}" | |
- uses: finebits/github-actions/pre-build/replace@v1 | |
with: | |
file: ./src/Eppie.CLI/Eppie.CLI/Options/AuthorizationOptions.cs | |
placeholder: '\"<Gmail-ClientSecret>\"' | |
value: "${{ secrets.GMAIL_CLIENT_SECRET }}" | |
- uses: finebits/github-actions/pre-build/replace@v1 | |
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.suffix-githash-version }}" | |
version-short: "${{ steps.version-number.outputs.suffix-version }}" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ env.output-name }}-${{ env.runtime }} [${{ env.version-short }}]" | |
path: "${{ env.output-path }}" | |
env: | |
artifact-name: "${{ env.output-name }}" | |
version-short: "${{ steps.version-number.outputs.suffix-version }}" | |
upload-assets: | |
name: Upload Assets | |
if: github.event_name == 'release' | |
needs: publish | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
artifacts-root: artifacts | |
assets-root: assets | |
steps: | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
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'" | |
else | |
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'" | |
fi | |
fi | |
done | |
- name: Upload All Assets | |
uses: finebits/github-actions/upload-release-asset@v1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.event.release.tag_name }} | |
path: "${{ env.assets-root }}/*" |