-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Create Release from Manifest | ||
|
||
on: | ||
push: | ||
branches: | ||
- Main | ||
paths: | ||
- "bin/**" | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
|
||
- name: Extract version from manifest.json | ||
id: get_version | ||
run: | | ||
VERSION=$(jq -r '.version' manifest.json) | ||
echo "Extracted version: $VERSION" | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Find the zip file in bin | ||
id: find_zip | ||
run: | | ||
ZIP_FILE=$(find ./bin -type f -name "*.zip") | ||
ZIP_BASENAME=$(basename "$ZIP_FILE") | ||
echo "Found zip file: $ZIP_FILE" | ||
echo "ZIP_FILE=$ZIP_FILE" >> $GITHUB_ENV | ||
echo "ZIP_BASENAME=$ZIP_BASENAME" >> $GITHUB_ENV # Save the zip file's name without the path | ||
- name: Check for existing release | ||
id: check_release | ||
run: | | ||
RELEASE=$(gh release view "v${{ env.VERSION }}" --json name --jq '.name' || echo "") | ||
if [ -n "$RELEASE" ]; then | ||
echo "Existing release found: $RELEASE" | ||
echo "RELEASE_EXISTS=true" >> $GITHUB_ENV | ||
else | ||
echo "No existing release found." | ||
echo "RELEASE_EXISTS=false" >> $GITHUB_ENV | ||
fi | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.VERSION }} | ||
name: Extension @${{ env.VERSION }} | ||
body: "Release created/updated with version ${{ env.VERSION }}" | ||
draft: false | ||
prerelease: false | ||
overwrite: true | ||
|
||
- name: Attach zip file with clean name to release | ||
if: env.RELEASE_EXISTS == 'false' || steps.create_or_update_release.outputs.upload_url | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ env.ZIP_FILE }} # Full path zip file | ||
asset_name: ${{ env.ZIP_BASENAME }} # Clean zip file name without the path | ||
asset_content_type: application/zip |