Skip to content

Commit

Permalink
feat: publish releases
Browse files Browse the repository at this point in the history
  • Loading branch information
suphon-t committed Jan 10, 2024
1 parent 4c1a8b7 commit 20a3545
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@ on:
push:
branches:
- main
tags:
- "v*.*.*"

permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read

jobs:
build:
runs-on: macos-13
Expand Down Expand Up @@ -72,3 +87,25 @@ jobs:
with:
name: ${{ env.PRODUCT_NAME }}.dmg
path: Build/${{ env.PRODUCT_NAME }}.dmg

- name: Prepare for release
if: startsWith(github.ref, 'refs/tags/')
run: |
set -e
VERSION=$(cat package.json | jq -r .version)
DMG_NAME="Build/${{ env.PRODUCT_NAME }}-v$VERSION.dmg"
CHANGELOG_PATH="$RUNNER_TEMP/CHANGELOG.md"
./scripts/changelog $VERSION > $CHANGELOG_PATH
cp Build/${{ env.PRODUCT_NAME }}.dmg $DMG_NAME
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "DMG_NAME=$DMG_NAME" >> "$GITHUB_ENV"
echo "CHANGELOG_PATH=$CHANGELOG_PATH" >> "$GITHUB_ENV"
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: ${{ env.CHANGELOG_PATH }}
files: ${{ env.DMG_NAME }}
4 changes: 3 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_PAT }}

- uses: pnpm/action-setup@v2
with:
Expand All @@ -45,7 +47,7 @@ jobs:
id: changesets
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
version: pnpm run version
publish: pnpm changeset tag
1 change: 1 addition & 0 deletions Build/DotLocal.dmg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dummy file
33 changes: 33 additions & 0 deletions scripts/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -e

VERSION=$1
if [ -z "$VERSION" ]; then
echo "usage: $0 <version>"
exit 1
fi

# read CHANGELOG.md line by line
# if line starts with ## $VERSION, print all lines until next ##

STATE='find_version'

while read -r line; do
if [[ $STATE == 'find_version' ]]; then
if [[ $line == "## $VERSION"* ]]; then
STATE='print_until_next_version'
fi
elif [[ $STATE == 'print_until_next_version' ]]; then
if [[ $line == "## "* ]]; then
break
else
echo $line
fi
fi
done < CHANGELOG.md

if [[ $STATE == 'find_version' ]]; then
echo "Could not find beginning of version $VERSION"
exit 1
fi

0 comments on commit 20a3545

Please sign in to comment.