Skip to content

Commit

Permalink
chore(ci): fix and update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant committed Jan 30, 2024
1 parent c86d223 commit b9b4d34
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 59 deletions.
9 changes: 2 additions & 7 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"projectName": "prettier-plugin-embed",
"projectOwner": "Sec-ant",
"files": [
"README.md"
],
"files": ["README.md"],
"commitType": "docs",
"commitConvention": "angular",
"contributorsPerLine": 7,
Expand All @@ -13,10 +11,7 @@
"name": "Karl Horky",
"avatar_url": "https://avatars.githubusercontent.com/u/1935696?v=4",
"profile": "https://upleveled.io",
"contributions": [
"code",
"doc"
]
"contributions": ["code", "doc"]
}
]
}
20 changes: 9 additions & 11 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
name: Dependabot auto-merge
name: Dependabot Auto Merge

on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
dependabot-auto-merge:
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Dependabot metadata
- name: Dependabot Metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Enable Auto Merge for Dependabot PRs
if: ${{steps.metadata.outputs.dependency-group == 'minor-and-patch-updates'}}
run: gh pr merge --auto --rebase "$PR_URL"
run: gh pr merge --auto --rebase $PR_URL
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Dispatch event
uses: peter-evans/repository-dispatch@v2
with:
event-type: dependabot-merge
87 changes: 57 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@ name: Release

on:
workflow_dispatch:
inputs:
mode:
description: "Release mode"
required: true
default: "no publish"
type: choice
options:
- "no publish"
- "publish"
push:
branches:
- main

permissions:
contents: write
issues: write
pull-requests: write
packages: write

env:
NPM_CONFIG_PROVENANCE: true

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
if: ${{ github.repository != 'Sec-ant/vanilla-ts' }}
runs-on: ubuntu-latest
permissions:
contents: write
env:
NPM_CONFIG_PROVENANCE: true
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand All @@ -37,33 +33,64 @@ jobs:
- name: Install Dependencies
run: npm ci

- name: Get Package Version
id: package-version
uses: martinbeentjes/[email protected]
- name: Get Commit ID
if: ${{ github.event_name == 'workflow_dispatch' }}
id: get-commit-id
run: |
echo "short-commit-id=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_OUTPUT
echo "commit-id=$(git rev-parse $GITHUB_SHA)" >> $GITHUB_OUTPUT
- name: Get Package Name
if: ${{ github.event_name == 'workflow_dispatch' }}
id: get-package-name
run: echo "package-name=$(npm pkg get name | jq -r)" >> $GITHUB_OUTPUT

- name: No Publish Build and Pack
if: ${{ github.event_name == 'workflow_dispatch' && inputs.mode == 'no publish' }}
- name: Get Normalized Package Name
if: ${{ github.event_name == 'workflow_dispatch' }}
id: get-normalized-package-name
uses: frabert/replace-string-action@v2
with:
pattern: "^.*?([^/]+)$"
string: ${{ steps.get-package-name.outputs.package-name }}
replace-with: "$1"

- name: Patch package.json
if: ${{ github.event_name == 'workflow_dispatch' }}
run: npm pkg set version=${{ steps.get-commit-id.outputs.short-commit-id }}

- name: Build and Pack
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
npm run build
npm run prepublishOnly
npm pack
- name: No Publish Artifact Upload
if: ${{ github.event_name == 'workflow_dispatch' && inputs.mode == 'no publish' }}
uses: actions/upload-artifact@v4
- name: Draft Release
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: ncipollo/release-action@v1
with:
name: package-artifact
path: prettier-plugin-embed-${{steps.package-version.outputs.current-version}}.tgz
retention-days: 1
overwrite: true
allowUpdates: true
artifacts: "${{ steps.get-normalized-package-name.outputs.replaced }}-${{ steps.get-commit-id.outputs.short-commit-id }}.tgz"
artifactContentType: application/gzip
body: "This is a draft release of ${{ steps.get-package-name.outputs.package-name }}: ${{ steps.get-commit-id.outputs.short-commit-id }}."
commit: ${{ steps.get-commit-id.outputs.commit-id }}
tag: "draft"
draft: true
name: "draft"
removeArtifacts: true

- name: Get Next Package Version
if: ${{ github.event_name != 'workflow_dispatch' }}
id: package-version
run: echo "version=$(npx changeset status --output=release.json && jq -r '.releases[0].newVersion // '$(npm pkg get version)'' release.json && rm release.json)" >> $GITHUB_OUTPUT

- name: Create Release Pull Request or Publish to npm
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.mode == 'publish') }}
- name: Create Release Pull Request or Publish to NPM
if: ${{ github.event_name != 'workflow_dispatch' }}
id: changesets
uses: changesets/action@v1
with:
version: npm run bump
publish: npx changeset publish
commit: "chore(release): v${{steps.package-version.outputs.current-version}}"
commit: "chore(release): v${{ steps.package-version.outputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [
"*.{js,ts,cjs,mjs,cts,mts,d.cts,d.mts,jsx,tsx,json,jsonc}": [
"biome check --apply --no-errors-on-unmatched --files-ignore-unknown=true"
],
"*.md": ["prettier --write --no-config"]
"*.{md,yml,yaml,css,html}": ["prettier --write"]
}
12 changes: 12 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.js
*.ts
*.cjs
*.mjs
*.cts
*.mts
*.d.cts
*.d.mts
*.jsx
*.tsx
*.json
*.jsonc
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
Expand All @@ -17,8 +18,5 @@
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@
"scripts": {
"update-hooks": "simple-git-hooks",
"changeset": "changeset",
"bump": "changeset version 2>/dev/null | grep . && npm i",
"bump": "changeset version 2>/dev/null | grep . && npm i; exit 0",
"dev": "vite",
"lint": "biome lint .",
"type-check": "tsc --noEmit --emitDeclarationOnly false",
"format": "biome format . --write",
"check": "biome check --apply .",
"format:prettier": "prettier . --write",
"format:biome": "biome format . --write",
"format": "conc \"npm:format:prettier\" \"npm:format:biome\"",
"check:biome": "biome check --apply .",
"check": "conc \"npm:format:prettier\" \"npm:check:biome\"",
"prebuild": "npm run check && npm run type-check",
"build": "vite build",
"add-glob-import-types": "tsx ./scripts/add-glob-import-types.ts",
Expand All @@ -82,7 +85,7 @@
"restore-readme": "tsx ./scripts/restore-readme",
"prepublishOnly": "npm run build && npm run process-readme",
"postpublish": "npm run restore-readme",
"ncu": "npx ncu",
"ncu": "ncu",
"postncu": "npm i",
"bump-biome": "npm i @biomejs/biome@latest --save-exact"
},
Expand Down
3 changes: 1 addition & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export default defineConfig({
index: "./src/index.ts",
},
formats: ["es"],
fileName: (format, entryName) =>
format === "es" ? `${entryName}.js` : `${entryName}.${format}.js`,
fileName: (_, entryName) => `${entryName}.js`,
},
rollupOptions: {
external: [...reject, ...builtinModules, /^node:/],
Expand Down

0 comments on commit b9b4d34

Please sign in to comment.