update readme #4
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
name: Release Workflow | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install Dependencies and Build | |
id: build | |
run: | | |
npm install -g pnpm && pnpm install && pnpm run build | |
echo "::set-output name=zip_path::$(pwd)/package.zip" | |
- name: Get Current Version | |
id: version | |
run: echo "::set-output name=version::$(node -p "require('./package.json').version")" | |
- name: Check for Existing Release | |
id: check_release | |
run: | | |
current_version="${{ steps.version.outputs.version }}" | |
if git rev-parse -q --verify "refs/tags/v$current_version"; then | |
echo "Release $current_version already exists. Nothing to do." | |
exit 0 | |
fi | |
commit_message=$(git log -1 --pretty=%B) | |
release_title="v$current_version" | |
echo "Creating release $release_title" | |
release_id=$(curl -s -X POST -H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" -d "{\"tag_name\": \"$release_title\", \"name\": \"$release_title\", \"body\": \"$commit_message\"}" "https://api.github.com/repos/${{ github.repository }}/releases" | jq -r '.id') | |
zip_path="${{ steps.build.outputs.zip_path }}" | |
echo "Uploading binary to release $release_id" | |
curl -s -X POST -H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" -H "Content-Type: application/zip" --data-binary "@$zip_path" "https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=package.zip" |