file extensions #5
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: Publish to GitHub Releases | |
on: | |
push: | |
branches: [master] | |
jobs: | |
build-and-deploy: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache dependencies and build outputs | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: "${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}" | |
restore-keys: ${{ runner.os }}-node- | |
- name: Install dependencies | |
run: yarn install | |
- name: Check version changes | |
id: check-version | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
if git tag | grep -q "v$VERSION"; then | |
echo "The version has not changed." | |
echo "::set-output name=changed::false" | |
else | |
echo "The version has changed." | |
echo "::set-output name=changed::true" | |
fi | |
- name: Build | |
run: npm run build | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build | |
path: | | |
dist/*.exe | |
dist/*.dmg | |
dist/*.AppImage | |
dist/*.deb | |
dist/*.snap | |
- name: Extract release notes | |
id: release-notes | |
run: | | |
RELEASE_NOTES=$(awk -v version="$VERSION" '/## \[/{flag=0} /## \['$version'\]/{flag=1} flag' CHANGELOG.md) | |
echo "RELEASE_NOTES=$RELEASE_NOTES" >> $GITHUB_ENV | |
- name: Create a GitHub Release | |
if: steps.check-version.outputs.changed == 'true' | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: v${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
body: | | |
**What's new in this release?** | |
${{ env.RELEASE_NOTES }} | |