Skip to content

Merge pull request #412 from terwer/release-please--branches--main--c… #85

Merge pull request #412 from terwer/release-please--branches--main--c…

Merge pull request #412 from terwer/release-please--branches--main--c… #85

on:
push:
branches:
- main
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
# Create release
- name: Create release
uses: google-github-actions/release-please-action@v4
id: release
with:
# this assumes that you have created a personal access token
# (PAT) and configured it as a GitHub action secret named
# `GH_TOKEN` (this secret name is not important).
token: ${{ secrets.GH_TOKEN }}
# optional. customize path to release-please-config.json
config-file: release-please-config.json
# optional. customize path to .release-please-manifest.json
manifest-file: .release-please-manifest.json
# Checkout
- name: Checkout
uses: actions/checkout@v3
if: ${{ steps.release.outputs.release_created }}
# Install Node.js
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
# Install pnpm
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 8
run_install: false
if: ${{ steps.release.outputs.release_created }}
# Get pnpm store directory
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
if: ${{ steps.release.outputs.release_created }}
# Setup pnpm cache
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
if: ${{ steps.release.outputs.release_created }}
# Install dependencies
- name: Install dependencies
run: pnpm install
if: ${{ steps.release.outputs.release_created }}
# Prepare new version
# https://github.com/google-github-actions/release-please-action#outputs
- name: Prepare new version
run: |
pnpm prepareRelease
if: ${{ steps.release.outputs.release_created }}
# Build for production and Archive package
- name: Build for production
run: pnpm package
if: ${{ steps.release.outputs.release_created }}
# Build for production and Archive package
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
pnpm publish -F universal-picgo-store --tag latest
pnpm publish -F universal-picgo --tag latest
pnpm publish -F zhi-siyuan-picgo --tag latest
if: ${{ steps.release.outputs.release_created }}
# Upload package to release
# https://github.com/philips-labs/terraform-aws-github-runner/blob/main/.github/workflows/release.yml#L46
- name: Upload package.zip to the release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
for f in $(find ./build -name '*.zip'); do
gh release upload ${{ steps.release.outputs.tag_name }} $f
done
if: ${{ steps.release.outputs.releases_created }}