Skip to content

Commit

Permalink
Merge pull request #78 from takuma-ru/refactor/77
Browse files Browse the repository at this point in the history
♻️ Improved development setup
  • Loading branch information
takuma-ru authored Dec 3, 2024
2 parents 708bb7a + 55e3e76 commit 43e51c5
Show file tree
Hide file tree
Showing 111 changed files with 12,557 additions and 9,840 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Set git config
run: |
Expand All @@ -31,7 +32,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 8.14.1
version: 9.12.2
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -72,7 +73,7 @@ jobs:
path: "**/node_modules"
key: ${{ runner.os }}-pnpm-store-${{ needs.init.outputs.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Type check
run: pnpm asg lint:type-check
run: pnpm p:core lint:type-check

eslint-check:
runs-on: ubuntu-latest
Expand All @@ -87,7 +88,7 @@ jobs:
path: "**/node_modules"
key: ${{ runner.os }}-pnpm-store-${{ needs.init.outputs.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: ESlint check
run: pnpm asg lint
run: pnpm p:core lint

build-check:
runs-on: ubuntu-latest
Expand All @@ -102,9 +103,20 @@ jobs:
path: "**/node_modules"
key: ${{ runner.os }}-pnpm-store-${{ needs.init.outputs.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Build check
run: pnpm asg build
run: pnpm p:core build

publish-check:
permissions:
contents: write
packages: write
actions: write
checks: write
deployments: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
id-token: write
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [init, build-check]
Expand All @@ -116,7 +128,5 @@ jobs:
with:
path: "**/node_modules"
key: ${{ runner.os }}-pnpm-store-${{ needs.init.outputs.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Build check
run: pnpm asg build
- name: Publish check
run: pnpm asg publish --dry-run --no-git-checks
run: pnpm p:core release:test
162 changes: 33 additions & 129 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -1,166 +1,70 @@
name: Release @takuma-ru/auto-story-generator package

run-name: Release ${{ inputs.releaseLevel }} version
name: Publish Package

on:
workflow_dispatch:
inputs:
releaseLevel:
description: "Release level"
pre:
description: 'Is this a NEW pre-release?'
required: false
default: false
type: boolean
level:
description: 'Release level'
required: true
default: patch
default: 'patch'
type: choice
options:
- major
- minor
- patch
- prerelease
isBeta:
description: "Is beta release (exp: X.X.X-beta.0)"
required: false
type: boolean
- minor
- major
- preup

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
checks: write
contents: write
deployments: write
issues: write
packages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
id-token: write
environment:
name: Publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max_old_space_size=8192

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Set git config
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Setup node
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
registry-url: "https://registry.npmjs.org/"

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8.14.1
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
node-version-file: package.json
registry-url: 'https://registry.npmjs.org'

# - 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-
- uses: pnpm/action-setup@v4

- name: Install Node Dependencies
run: pnpm install
- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Set .npmrc
run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > packages/auto-story-generator/.npmrc
- name: Build
run: pnpm p:core build

- name: Set beta value
id: beta
- name: Release
run: |
if [[ "${{ inputs.isBeta }}" == "true" ]]; then
echo "beta=beta" >> $GITHUB_OUTPUT
if [ "${{ github.event.inputs.pre }}" == "true" ]; then
pnpm p:core release --level ${{ github.event.inputs.level }} --pre
else
echo "beta=" >> $GITHUB_OUTPUT
pnpm p:core release --level ${{ github.event.inputs.level }}
fi
- name: Release
id: release
run: |
OUTPUT=$(node ./.scripts/release.cjs ${{ inputs.releaseLevel }} ${{ steps.beta.outputs.beta }})
LAST_LINE=$(echo "$OUTPUT" | tail -n 1)
echo "branchName=$LAST_LINE" >> $GITHUB_OUTPUT
shell: bash

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
if: steps.release.outcome == 'success'
with:
title: ":bookmark: Update package.json"
draft: false
base: main
branch: ${{ steps.release.outputs.branchName }}
assignees: "${{ github.actor }}"

create-github-release:
needs: release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

environment:
name: Publish

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set git config
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
registry-url: "https://registry.npmjs.org/"

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8.14.1
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 Node Dependencies
run: pnpm install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Get Current package info
id: get-package-info
Expand All @@ -174,4 +78,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ steps.get-package-info.outputs.PACKAGE_VERSION }}
prerelease: ${{ contains(steps.get-package-info.outputs.PACKAGE_VERSION, '-beta') }}
prerelease: ${{ contains(steps.get-package-info.outputs.PACKAGE_VERSION, '-beta') }}
90 changes: 77 additions & 13 deletions asg.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,87 @@
},
],
"settings": {
"cSpell.words": [
"consola",
"magicast",
"satoshi",
"scule",
"vitepress",
"vumdoc",
],
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"prettier.enable": false,
"biome.enabled": false,
"stylelint.enable": false,

"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.addMissingImports": "explicit",
"source.organizeImports": "never"
},

"[javascript]": {
"editor.codeActionsOnSave": {
"source.addMissingImports": "explicit",
}
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.addMissingImports": "explicit",
}
},
"[vue]": {
"editor.codeActionsOnSave": {
"source.addMissingImports": "explicit",
}
},
"files.eol": "\n",

"eslint.options": {
"flags": ["unstable_ts_config"]
},

"eslint.runtime": "node",

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off", "fixable": true },
{ "rule": "*-indent", "severity": "off", "fixable": true },
{ "rule": "*-spacing", "severity": "off", "fixable": true },
{ "rule": "*-spaces", "severity": "off", "fixable": true },
{ "rule": "*-order", "severity": "off", "fixable": true },
{ "rule": "*-dangle", "severity": "off", "fixable": true },
{ "rule": "*-newline", "severity": "off", "fixable": true },
{ "rule": "*quotes", "severity": "off", "fixable": true },
{ "rule": "*semi", "severity": "off", "fixable": true }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"svelte",
"css",
"less",
"scss",
"pcss",
"postcss"
],

"typescript.preferences.importModuleSpecifier": "non-relative",
"javascript.preferences.importModuleSpecifier": "non-relative",
"emmet.triggerExpansionOnTab": true,

"cSpell.words": [
"antfu"
],

"terminal.integrated.cwd": "${workspaceFolder}"
},
"extensions": {},
}
Loading

0 comments on commit 43e51c5

Please sign in to comment.