Skip to content

Merge pull request #70 from sgratzl/release/v2.4.6 #11

Merge pull request #70 from sgratzl/release/v2.4.6

Merge pull request #70 from sgratzl/release/v2.4.6 #11

name: Release Helper
on:
push:
branches:
- main
jobs:
correct_repository:
runs-on: ubuntu-latest
steps:
- name: fail on fork
if: github.repository_owner != 'sgratzl'
run: exit 1
create_release:
needs: correct_repository
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Extract version
id: extract_version
run: |
node -pe "'version=' + require('./package.json').version" >> $GITHUB_OUTPUT
node -pe "'npm_tag=' + (require('./package.json').version.includes('-') ? 'next' : 'latest')" >> $GITHUB_OUTPUT
- name: Print version
run: |
echo "releasing ${{ steps.extract_version.outputs.version }} with tag ${{ steps.extract_version.outputs.npm_tag }}"
- name: Create Release
id: create_release
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: v${{ steps.extract_version.outputs.version }}
tag: v${{ steps.extract_version.outputs.version }}
version: ${{ steps.extract_version.outputs.version }}
prerelease: ${{ needs.create_release.outputs.tag_name == 'next' }}
publish: true
outputs:
version: ${{ steps.extract_version.outputs.version }}
npm_tag: ${{ steps.extract_version.outputs.npm_tag }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
tag_name: ${{ steps.create_release.outputs.tag_name }}
build_assets:
needs: create_release
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i -g yarn
- run: yarn config set checksumBehavior ignore
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: |
./.yarn/cache
./.yarn/unplugged
key: ${{ runner.os }}-yarn2-v4-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn2-v4
- run: yarn install
- run: yarn build
- run: yarn pack
- name: Upload Release Asset
uses: AButler/[email protected]
with:
files: 'package.tgz'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ needs.create_release.outputs.tag_name }}
- name: Pack Publish
run: |
yarn config set npmAuthToken "${{ secrets.NPM_TOKEN }}"
yarn pack
yarn npm publish --tag "${{ needs.create_release.outputs.npm_tag }}"
sync_dev:
needs: correct_repository
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: dev
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
- name: Reset dev branch
run: |
git fetch origin main:main
git merge main
git push