Skip to content

Commit

Permalink
refactor: migrate project to TypeScript and Rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
liby committed Aug 7, 2024
1 parent 3a6677d commit 02e32e8
Show file tree
Hide file tree
Showing 22 changed files with 1,733 additions and 1,097 deletions.
88 changes: 59 additions & 29 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Release
name: Bump Version and Release

on:
push:
tags: [ v\d+\.\d+\.\d+ ]

workflow_dispatch:
inputs:
version:
description: 'Tag version (e.g., 1.0.0 or v1.0.0)'
required: true
message:
description: 'Tag message'
required: true

jobs:
release:
Expand All @@ -14,52 +19,77 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}

- name: Get version
id: get_version
uses: battila7/get-version-action@v2
- name: Set up Git
run: |
git config --global user.name 'GitHub Actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Get tag message
id: tag
- name: Determine tag version
id: determine_version
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo "message=$(git tag -l --format='%(contents:subject)' ${{ steps.get_version.outputs.version }})" >> $GITHUB_OUTPUT
VERSION="${{ github.event.inputs.version }}"
if [[ $VERSION != v* ]]; then
VERSION="v$VERSION"
fi
VERSION_NUMBER="${VERSION#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_ENV
- name: Change version
- name: Update info.json
run: |
OLD_VERSION=$(grep '"version":' src/info.json | awk -F\" '{print $4}')
sed -i "s/$OLD_VERSION/${{ steps.get_version.outputs.version-without-v }}/" src/info.json
OLD_VERSION=$(grep '"version":' public/info.json | awk -F\" '{print $4}')
sed -i "s/$OLD_VERSION/${{ env.VERSION_NUMBER }}/" public/info.json
- name: Package plugin
run: mkdir release && zip -j -r release/openai-polisher-${{ steps.get_version.outputs.version-without-v }}.bobplugin ./src/*
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm

- run: pnpm install
- run: pnpm run build

- run: git checkout -- src/
- name: Package plugin
run: |
zip -j -r dist/openai-polisher-${{ env.VERSION_NUMBER }}.bobplugin ./dist/*
echo "Packaged file: dist/openai-polisher-${{ env.VERSION_NUMBER }}.bobplugin"
- name: Update appcast.json
env:
VERSION_NUMBER: ${{ env.VERSION_NUMBER }}
MESSAGE: ${{ github.event.inputs.message }}
run: |
python3 scripts/update_release.py ${{ steps.get_version.outputs.version-without-v }} '${{ steps.tag.outputs.message }}'
python3 scripts/update_appcast.py "$VERSION_NUMBER" "$MESSAGE"
- name: Commit files
run: |
git config --global user.name 'Bryan Lee'
git config --global user.email '[email protected]'
git commit -am 'chore: update appcast.json and info.json'
git commit -a -m 'chore: update appcast.json and info.json'
- name: Create tag
env:
VERSION: ${{ env.VERSION }}
MESSAGE: ${{ github.event.inputs.message }}
run: |
git tag -a "$VERSION" -m "$MESSAGE"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.PAT }}
tags: true

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
release_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ env.VERSION }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: release/openai-polisher-${{ steps.get_version.outputs.version-without-v }}.bobplugin
asset_name: openai-polisher-${{ steps.get_version.outputs.version-without-v }}.bobplugin
tag: ${{ github.ref }}
file: dist/openai-polisher-${{ env.VERSION_NUMBER }}.bobplugin
asset_name: openai-polisher-${{ env.VERSION_NUMBER }}.bobplugin
tag: ${{ env.VERSION }}
overwrite: true
body: ${{ steps.tag.outputs.message }}
body: ${{ github.event.inputs.message }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*.bobplugin
*.log*
dist
node_modules
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.16.0
Loading

0 comments on commit 02e32e8

Please sign in to comment.