Skip to content

Merge pull request #497 from zenn-dev/canary #70

Merge pull request #497 from zenn-dev/canary

Merge pull request #497 from zenn-dev/canary #70

name: Publish latest version
on:
push:
branches:
- main
paths-ignore:
- '**/package.json'
- 'lerna.json'
- '**.md'
- 'packages/example/**'
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup node
uses: actions/setup-node@v2
with:
cache: 'pnpm'
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: ビルド時に使用する環境変数を設定
run: |
touch ./packages/zenn-cli/.env
echo VITE_EMBED_SERVER_ORIGIN=${{ vars.VITE_EMBED_SERVER_ORIGIN }} >> ./packages/zenn-cli/.env
- name: パッケージをインストール
run: pnpm install
# Enable lerna to commit on GitHub.
# Note that this does not work with protected branch.
- name: Configure git identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: pnpm build
# zenn-editor packages does not follow semantic versioning.
# This is because anyone should use latest version which is synced with zenn.dev
- name: Bump version to latest
run: pnpm lerna version patch --yes --no-private
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set released version to env
run: node -p -e '`RELEASED_PACKAGE_VERSION=${require("./lerna.json").version}`' >> $GITHUB_ENV
- name: Create release
uses: release-drafter/release-drafter@v5
with:
version: ${{ env.RELEASED_PACKAGE_VERSION }}
name: ${{ env.RELEASED_PACKAGE_VERSION }}
tag: ${{ env.RELEASED_PACKAGE_VERSION }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish latest
run: pnpm lerna publish from-package --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v2
with:
ref: canary
- name: Reflect changes on main branch to canary branch.
run: |
git pull origin main
git push origin HEAD