Skip to content

Commit

Permalink
Update Publish.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Spooks4576 committed Mar 23, 2024
1 parent 1d48d5a commit 8ba4edf
Showing 1 changed file with 5 additions and 42 deletions.
47 changes: 5 additions & 42 deletions .github/workflows/Publish.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Build and Release PlatformIO Project

on:
push:
branches:
- main
release:
types: [created]

jobs:
build:
Expand Down Expand Up @@ -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

0 comments on commit 8ba4edf

Please sign in to comment.