ci: use release-please

This commit is contained in:
2024-09-16 22:15:04 +03:00
committed by Chen Asraf
parent ff4ebf0a5b
commit a275e688d4
7 changed files with 99 additions and 2496 deletions

33
.github/workflows/develop.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: Test
on:
pull_request:
branches:
- master
- develop
permissions:
contents: write
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i -g pnpm
- run: pnpm run ci
- run: pnpm test
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i -g pnpm
- run: pnpm run ci
- run: pnpm build

View File

@@ -1,11 +1,13 @@
name: Documentation
permissions:
contents: write
on:
push:
branches: [master, pre, develop]
branches:
- master
- develop
permissions:
contents: write
jobs:
docs:
@@ -13,22 +15,15 @@ jobs:
runs-on: ubuntu-latest
# if: "contains(github.event.head_commit.message, 'chore(release)')"
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install PNPM
run: npm i -g pnpm
- name: Install dependencies
run: |
node-version: 20
- run: npm i -g pnpm
- run: |
pnpm install --frozen-lockfile
cd docs && pnpm install --frozen-lockfile
- name: Build Docs
run: pnpm docs:build
- run: pnpm docs:build
- name: Deploy on GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:

View File

@@ -1,26 +0,0 @@
name: Pull Requests
on:
pull_request:
branches: [master, pre, develop]
jobs:
build:
name: Test & Build PR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install PNPM
run: npm i -g pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run Tests
run: pnpm test
- name: Build Package
run: pnpm build

View File

@@ -2,37 +2,62 @@ name: Release
on:
push:
branches: [master, pre, develop]
branches:
- master
permissions:
contents: read # for checkout
contents: write
pull-requests: write
jobs:
release:
name: Release
test:
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
node-version: 20
- run: npm i -g pnpm
- run: pnpm run ci
- run: pnpm test
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install PNPM
run: npm i -g pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run Tests
run: pnpm test
- name: Build Package
run: pnpm build
- name: Semantic Release
run: npx semantic-release
node-version: 20
- run: npm i -g pnpm
- run: pnpm run ci
- run: pnpm build
release:
needs:
- build
- test
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
release-type: node
publish:
needs: release
runs-on: ubuntu-latest
if: ${{ needs.release.outputs.release_created }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- run: npm i -g pnpm
- run: pnpm run ci
- run: pnpm build
- run: cd build && npm publish
env:
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@@ -13,7 +13,7 @@
"bin": {
"simple-scaffold": "cmd.js"
},
"packageManager": "pnpm@9.8.0",
"packageManager": "pnpm@9.9.0",
"keywords": [
"javascript",
"cli",
@@ -35,7 +35,7 @@
"docs:build": "cd docs && pnpm build",
"docs:watch": "cd docs && pnpm start",
"audit-fix": "pnpm audit --fix",
"changelog": "conventional-changelog -i CHANGELOG.md -s -r 0; echo \"# Change Log\n\n$(cat CHANGELOG.md)\" > CHANGELOG.md"
"ci": "pnpm install --frozen-lockfile"
},
"dependencies": {
"date-fns": "^3.6.0",
@@ -44,20 +44,11 @@
"massarg": "2.0.1"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/release-notes-generator": "^14.0.1",
"@types/jest": "^29.5.12",
"@types/mock-fs": "^4.13.4",
"@types/node": "^22.5.0",
"@types/semantic-release": "^20.0.6",
"conventional-changelog": "^6.0.0",
"conventional-changelog-cli": "^5.0.0",
"jest": "^29.7.0",
"mock-fs": "^5.2.0",
"semantic-release": "^24.1.0",
"semantic-release-conventional-commits": "^3.0.0",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"

2348
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,67 +0,0 @@
const ref = process.env.GITHUB_REF || ""
const branch = ref.split("/").pop()
/**
* @type {import('semantic-release').GlobalConfig}
*/
module.exports = {
branches: ["master", { name: "pre", prerelease: true }],
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/npm",
{
// only update the pkg version on root, don't publish
// this is to keep package.json version in sync with the release
npmPublish: false,
},
],
[
"@semantic-release/exec",
{
// pack the dist folder, during publish step (after version was bumped)
publishCmd: 'echo "Packing..."; cd ./dist && pnpm pack --pack-destination=../; echo "Done"',
},
],
[
"@semantic-release/npm",
{
// publish from dist dir instead of root
// this is the actual uild output
pkgRoot: "dist",
},
],
[
// Release to GitHub
"@semantic-release/github",
{
assets: ["*.tgz"],
},
],
branch === "master"
? [
// Update CHANGELOG.md only on master
"@semantic-release/changelog",
{
changelogFile: "CHANGELOG.md",
changelogTitle: "# Change Log",
},
]
: undefined,
[
// Commit the package.json and CHANGELOG.md files to git (if modified)
"@semantic-release/git",
{
assets: ["package.json", "CHANGELOG.md"].filter(Boolean),
},
],
//
// [
// '@semantic-release/exec',
// {
// verifyReleaseCmd: 'echo ${nextRelease.version} > .VERSION',
// },
// ],
].filter(Boolean),
}