From 8ba4edfd47b8218e3380f09989f2ebc63ed41fe8 Mon Sep 17 00:00:00 2001 From: Spooks <62370103+Spooks4576@users.noreply.github.com> Date: Fri, 22 Mar 2024 20:35:07 -0600 Subject: [PATCH] Update Publish.yaml --- .github/workflows/Publish.yaml | 47 ++++------------------------------ 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/.github/workflows/Publish.yaml b/.github/workflows/Publish.yaml index ffcf8d20..8d877a3e 100644 --- a/.github/workflows/Publish.yaml +++ b/.github/workflows/Publish.yaml @@ -1,9 +1,8 @@ name: Build and Release PlatformIO Project on: - push: - branches: - - main + release: + types: [created] jobs: build: @@ -32,48 +31,12 @@ jobs: - name: Tar artifacts run: tar -czvf ${{ matrix.board }}.tar.gz -C .pio/build/${{ matrix.board }} firmware.bin partitions.bin bootloader.bin - # Check if the release already exists - - name: Check if Release Exists - id: check_release - uses: actions/github-script@v6 - with: - script: | - const octokit = github.rest; - const { data: releases } = await octokit.repos.listReleases({ - owner: context.repo.owner, - repo: context.repo.repo, - }); - const release = releases.find(release => release.tag_name === 'release'); - if (release) { - core.setOutput('exists', 'true'); - core.setOutput('upload_url', release.upload_url); - } else { - core.setOutput('exists', 'false'); - } - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # Create Release if it does not exist - - name: Create Release - if: steps.check_release.outputs.exists == 'false' - uses: softprops/action-gh-release@v1 - with: - files: ./${{ matrix.board }}.tar.gz - draft: false - tag_name: release - name: Ghost ESP Release - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # Upload assets if the release already exists + # Upload assets to the newly created release - name: Upload assets to Release - if: steps.check_release.outputs.exists == 'true' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ matrix.board }}.tar.gz asset_name: ${{ matrix.board }}.tar.gz - tag: release - overwrite: true - url: ${{ steps.check_release.outputs.upload_url }} + tag: ${{ github.ref_name }} # Use the tag name of the created release + overwrite: true \ No newline at end of file