From 273e6d546d8aa9fc9d05db7b0775aeaa05dc38ce Mon Sep 17 00:00:00 2001 From: antony-jr Date: Sun, 10 Dec 2023 20:23:53 +0530 Subject: [PATCH] only deploy on new release --- .github/workflows/deploy.yml | 56 ++++++++++++++++++++++++++++++------ .github/workflows/tests.yml | 1 + scripts/check.py | 35 ++++++++++++++++++++++ 3 files changed, 84 insertions(+), 8 deletions(-) create mode 100755 scripts/check.py diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2e561b13..b382a8da 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,14 +1,56 @@ name: Deploy Prebuilt on: - push: - branches: - - add-prebuilts + workflow_run: + workflows: ["Tests"] + branches: [add-prebuilts] + types: + - completed + +permissions: + contents: write jobs: + check: + runs-on: ubuntu-latest + outputs: + deploy: ${{ steps.git.outputs.deploy }} + steps: + - uses: actions/checkout@v3 + + - name: Install Python3 + run: | + sudo apt install -y python3 + + - id: git + name: Check Commit Message + run: | + git clone https://github.com/antony-jr/QArchive + cd QArchive + git tag > /tmp/tags.txt + cd .. + rm -rf QArchive + cat /tmp/tags.txt + result=$(python3 scripts/check.py "$(git log -1 --pretty=%B)" "/tmp/tags.txt") + echo "deploy=$result" >> $GITHUB_OUTPUT + + - id: make_rel + if: steps.git.outputs.deploy != 'false' + name: Make Relase + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.git.outputs.deploy}} + run: | + gh release create "$tag" \ + --repo="$GITHUB_REPOSITORY" \ + --title="$tag" \ + --generate-notes + windows-msvc: runs-on: windows-2019 + if: needs.check.outputs.deploy != 'false' name: windows-msvc-v${{ matrix.toolset }}-${{ matrix.arch }}-qt-${{ matrix.qt_version }}-${{ matrix.build_type }} + needs: check strategy: fail-fast: false matrix: @@ -68,8 +110,6 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ github.workspace }}/upload/windows-msvc-v${{ matrix.toolset }}-qt-${{ matrix.qt_version }}-${{ matrix.arch }}-${{ matrix.build_type }}.zip - tag: prebuilt - overwrite: true - prerelease: true - release_name: "Prebuilt Library" - body: "Prebuilt binaries for QArchive, to use with Qt prebuilds. (Work in Progress)" + tag: ${{ needs.check.outputs.deploy }} + overwrite: false + prerelease: false diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3687c713..1766d5a8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - add-prebuilts pull_request: branches: - master diff --git a/scripts/check.py b/scripts/check.py new file mode 100755 index 00000000..661c7dcd --- /dev/null +++ b/scripts/check.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +import sys + +if len(sys.argv) < 2: + print("Usage: check.py [GIT COMMIT MESSAGE] [OUTPUT OF git tags]") + sys.exit(-1) + +message = sys.argv[1]; +tags = sys.argv[2]; +if "Release" in message: + parts = message.split('[Release ') + if len(parts) != 2: + print("false") + sys.exit(0) + + parts2 = parts[1].split(']') + if len(parts2) != 2: + print("false") + sys.exit(0) + + version = parts2[0] + version = version.lower() + + # Check if there is a existing tag. + with open(tags, 'r') as fp: + for i in fp: + s = i.strip() + if version == s: + print("false") + sys.exit(0) + print(version) +else: + print("false") + sys.exit(0) +sys.exit(0)