Merge pull request #481 from zenn-dev/canary #66
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 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: Notifiy releases to zenn-dev/zenn | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
repository: zenn-dev/zenn | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
event-type: update-zenn-editor-packages # specify this on zenn workflows | |
client-payload: '{"commit_url": "https://github.com/zenn-dev/zenn-editor/commit/${{ github.sha }}"}' | |
- name: Notifiy releases to zenn-dev/api-markdown-html | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
repository: zenn-dev/api-markdown-html | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
event-type: update-zenn-editor-packages # specify this on zenn workflows | |
client-payload: '{"commit_url": "https://github.com/zenn-dev/zenn-editor/commit/${{ github.sha }}"}' | |
- 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 |