Skip to content

Add automated GitHub release workflow for the browser extension and b… #4

Add automated GitHub release workflow for the browser extension and b…

Add automated GitHub release workflow for the browser extension and b… #4

Workflow file for this run

name: Create GitHub Release
on:
push:
branches:
- master
paths:
- 'apps/editor/package.json'
- 'apps/browser/src/manifest.json'
# Required to allow the workflow to create tags and releases
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from package.json
id: package_version
run: |
VERSION=$(jq -r .version apps/editor/package.json)
echo "version=v$VERSION" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check_tag
run: |
# Prevent failing if package.json was modified but version wasn't bumped
if git ls-remote --tags origin refs/tags/${{ steps.package_version.outputs.version }} | grep -q 'refs/tags/'; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
if: steps.check_tag.outputs.exists == 'false'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup PNPM
if: steps.check_tag.outputs.exists == 'false'
uses: pnpm/action-setup@v2
with:
version: 9.6.0
run_install: false
- name: Install dependencies
if: steps.check_tag.outputs.exists == 'false'
run: pnpm i
- name: Build VS Code extension
if: steps.check_tag.outputs.exists == 'false'
run: |
cd apps/editor
pnpm build
- name: Generate Release Notes
if: steps.check_tag.outputs.exists == 'false'
run: |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
echo "### What's changed in VS Code extension:" > release_notes.md
echo "" >> release_notes.md
if [ -n "$PREV_TAG" ]; then
git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" -- apps/editor >> release_notes.md
else
git log --pretty=format:"* %s (%h)" -- apps/editor >> release_notes.md
fi
- name: Create Release and Upload VSIX
if: steps.check_tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.package_version.outputs.version }}
name: Release ${{ steps.package_version.outputs.version }}
body_path: release_notes.md
# Grab the compiled .vsix generated by 'vsce package'
files: apps/editor/*.vsix
release-browser:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from manifest.json
id: browser_version
run: |
VERSION=$(jq -r .version apps/browser/src/manifest.json)
echo "version=browser-v$VERSION" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check_tag
run: |
# Prevent failing if manifest.json was modified but version wasn't bumped
if git ls-remote --tags origin refs/tags/${{ steps.browser_version.outputs.version }} | grep -q 'refs/tags/'; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
if: steps.check_tag.outputs.exists == 'false'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup PNPM
if: steps.check_tag.outputs.exists == 'false'
uses: pnpm/action-setup@v2
with:
version: 9.6.0
run_install: false
- name: Install dependencies
if: steps.check_tag.outputs.exists == 'false'
run: pnpm i
- name: Build Browser extension
if: steps.check_tag.outputs.exists == 'false'
run: |
cd apps/browser
pnpm build
- name: Generate Release Notes
if: steps.check_tag.outputs.exists == 'false'
run: |
PREV_TAG=$(git describe --tags --match "browser-v*" --abbrev=0 2>/dev/null || echo "")
echo "### What's changed in Browser extension:" > release_notes_browser.md
echo "" >> release_notes_browser.md
if [ -n "$PREV_TAG" ]; then
git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" -- apps/browser >> release_notes_browser.md
else
git log --pretty=format:"* %s (%h)" -- apps/browser >> release_notes_browser.md
fi
- name: Create Release and Upload ZIPs
if: steps.check_tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.browser_version.outputs.version }}
name: Browser Extension Release ${{ steps.browser_version.outputs.version }}
body_path: release_notes_browser.md
files: apps/browser/*.zip