Skip to content

Commit

Permalink
only deploy on new release
Browse files Browse the repository at this point in the history
  • Loading branch information
antony-jr committed Dec 10, 2023
1 parent 1e3e477 commit 273e6d5
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 8 deletions.
56 changes: 48 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- add-prebuilts
pull_request:
branches:
- master
Expand Down
35 changes: 35 additions & 0 deletions scripts/check.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 273e6d5

Please sign in to comment.