Add publishing to winget (#795) #20
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: Handle tag | |
on: | |
push: | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+*' | |
workflow_dispatch: | |
jobs: | |
check-tag-branch: | |
# This job is based on replies in https://github.community/t/how-to-create-filter-on-both-tag-and-branch/16936/6 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get tag commit hash | |
id: tag-commit-hash | |
run: | | |
hash=${{ github.sha }} | |
echo "{name}=tag-hash::${hash}" >> $GITHUB_OUTPUT | |
echo $hash | |
- name: Checkout main | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Get latest main commit hash | |
id: main-commit-hash | |
run: | | |
hash=$(git log -n1 --format=format:"%H") | |
echo "{name}=main-hash::${hash}" >> $GITHUB_OUTPUT | |
echo $hash | |
- name: Verify tag commit matches main commit - exit if they don't match | |
if: steps.tag-commit-hash.outputs.tag-hash != steps.main-commit-hash.outputs.main-hash | |
run: | | |
echo "Tag was not on the main branch. Exiting." | |
exit 1 | |
get-version: | |
runs-on: windows-2022 | |
steps: | |
- name: Get version from tag | |
id: extract-tag | |
shell: bash | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Check output to get version number | |
run: | | |
echo "release_version is $env:RELEASE_VERSION" | |
if ($env:RELEASE_VERSION -eq $null -or $env:RELEASE_VERSION -eq '') { | |
echo "Setting release version to 0.0.0" | |
echo "RELEASE_VERSION=0.0.0" >> $env:GITHUB_ENV | |
} | |
outputs: | |
release-version: ${{ env.RELEASE_VERSION }} | |
call-build-test: | |
needs: [check-tag-branch, get-version] | |
uses: ./.github/workflows/build-test.yml | |
with: | |
release-version: ${{ needs.get-version.outputs.release-version }} | |
cache-build: true | |
publish-it: | |
needs: [check-tag-branch, get-version, call-build-test] | |
uses: ./.github/workflows/publish.yml | |
secrets: | |
CHOCO_TOKEN: ${{ secrets.CHOCOTOKEN }} | |
with: | |
release-version: ${{ needs.get-version.outputs.release-version }} | |