Trigger a workflow could fail due to tag already existing #8
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
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- 'assets/Version.ini' | |
permissions: | |
contents: write | |
# In this workflow the release version number is read from a .ini file. That is | |
# implemented by having one job read the file and print the key-value pair to | |
# the its output. Another job then uses the output value. | |
# | |
# - Output is generated by the `check` job, in the step Get version number. | |
# - The value is consumed in the `build` job. | |
# | |
# And see the reference documentation here. | |
# https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
outputs: | |
VersionNumber: ${{ steps.get_version_number.outputs.VersionNumber }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Get version number | |
id: get_version_number | |
run: | | |
python src/utils/readini.py\ | |
assets/Version.ini Release VersionNumber >> "$GITHUB_OUTPUT" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install ruff | |
- name: Analysing the code with ruff | |
run: | | |
ruff check . | |
# The build job runs on a Windows machine and performs various build steps. | |
build: | |
runs-on: windows-latest | |
needs: check | |
env: | |
# Convenience variable with a shorter name. | |
VersionNumber: ${{needs.check.outputs.VersionNumber}} | |
steps: | |
- name: Create tag | |
id: create_tag | |
uses: actions/github-script@v7 | |
with: | |
# https://stackoverflow.com/a/64479344/7657675 | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/v${{needs.check.outputs.VersionNumber}}", | |
sha: context.sha | |
}) | |
- name: Demo version number | |
run: | | |
New-Item delme-env-$Env:VersionNumber".txt" -type file | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
# - name: Freeze Installer | |
# run: | | |
# pyinstaller build.spec | |
# - name: Build Installer | |
# run: | | |
# iscc installer.iss | |
# - name: Freeze Portable | |
# run: | | |
# pyinstaller --distpath dist-portable build-portable.spec | |
# - name: Zip Portable | |
# shell: pwsh | |
# run: | | |
# Copy-Item -Path assets -Destination dist-portable\ -Recurse | |
# Copy-Item -Path configs -Destination dist-portable\ -Recurse | |
# Compress-Archive ` | |
# -Path dist-portable ` | |
# -DestinationPath FaceCommander-Portable-$Env:VersionNumber".zip" | |
# - name: release | |
# uses: softprops/action-gh-release@v1 | |
# with: | |
# files: | | |
# Output/FaceCommander-Installer-v${{needs.check.outputs.VersionNumber}}.exe | |
# FaceCommander-Portable-v${{needs.check.outputs.VersionNumber}}.zip | |
# name: v${{needs.check.outputs.VersionNumber}} | |
# draft: true | |
# prerelease: true | |
# fail_on_unmatched_files: true |