Skip to content

Commit

Permalink
Update action
Browse files Browse the repository at this point in the history
  • Loading branch information
npv2k1 committed Aug 8, 2023
1 parent 7d84b8a commit 6c35a1e
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 9 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
on:
push:
tags:
- "v*"

name: Create Release

jobs:
create-release:
name: Publish Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Pull all submodule
run: git submodule update --init --recursive

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "16"

- name: Setup Git
run: |
git config user.name '${{secrets.MAINTAINER_NAME}}'
git config user.email '${{secrets.MAINTAINER_EMAIL}}'
- name: Update package.json
run: |
# Extract the version from the git tag (e.g., "v1.0.0")
version=$(echo "${{ github.ref }}" | sed -e 's/^refs\/tags\/v//')
# Update the package.json version using Node.js script
node - <<EOF
const fs = require('fs');
const packageJson = JSON.parse(fs.readFileSync('package.json'));
packageJson.version = "$version";
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
EOF
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build nextjs pages
run: pnpm run build

- uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Publish Release
on:
push:
tags:
- 'v*'

name: Create Release
release:
types:
- published

jobs:
publish:
publish-release:
name: Publish Release
runs-on: ubuntu-latest
steps:
Expand All @@ -29,7 +28,7 @@ jobs:
- name: Update package.json
run: |
# Extract the version from the git tag (e.g., "v1.0.0")
version=$(echo "${{ github.ref }}" | sed -e 's/^refs\/tags\/v//')
version=$(echo "${{ github.event.release.tag_name }}" | sed -e 's/^refs\/tags\/v//')
# Update the package.json version using Node.js script
node - <<EOF
Expand Down Expand Up @@ -69,11 +68,10 @@ jobs:
- name: Publish
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
if [[ "${{ github.ref }}" == *"beta"* ]]; then
if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
npm publish --tag beta
else
npm publish
fi
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 6c35a1e

Please sign in to comment.