From 60ce857604530761a48e961cda41900efbf0a3c6 Mon Sep 17 00:00:00 2001 From: richardadonnell Date: Sun, 24 Nov 2024 18:50:24 -0500 Subject: [PATCH] Update auto-release.yml --- .github/workflows/auto-release.yml | 43 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 9b22b09..f65a6e7 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -1,39 +1,40 @@ name: Auto Release on: - push: - paths: - - "releases/*.zip" + workflow_run: + workflows: ["Create Release ZIP"] + types: + - completed + branches: + - main jobs: create-release: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} permissions: contents: write steps: - name: Checkout code uses: actions/checkout@v3 - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v39 - with: - files: releases/*.zip + - name: Find latest zip file + id: find-zip + run: | + LATEST_ZIP=$(ls -t releases/*.zip | head -n 1) + echo "zip_file=$LATEST_ZIP" >> $GITHUB_OUTPUT - name: Create Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - if [[ $file == releases/*.zip ]]; then - # Extract version from filename (assuming format: upwork-job-scraper-X.XX.zip) - VERSION=$(echo "$file" | sed -n 's/.*-\([0-9.]*\)\.zip$/\1/p') - FILENAME=$(basename "$file") - - # Create and publish release - gh release create "$VERSION" \ - --title "$FILENAME" \ - --notes "" \ - "$file" - fi - done + file="${{ steps.find-zip.outputs.zip_file }}" + # Extract version from filename (assuming format: upwork-job-scraper-X.XX.zip) + VERSION=$(echo "$file" | sed -n 's/.*-\([0-9.]*\)\.zip$/\1/p') + FILENAME=$(basename "$file") + + # Create and publish release + gh release create "$VERSION" \ + --title "$FILENAME" \ + --notes "" \ + "$file"