Skip to content

Commit

Permalink
chore: fix release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
FRSgit committed Apr 18, 2024
1 parent e81c9b9 commit f150146
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 158 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: CI
on:
pull_request:
branches:
Expand All @@ -8,9 +8,11 @@ on:
- main

jobs:
build-and-release:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -28,16 +30,14 @@ jobs:
- run: pnpm install --frozen-lockfile
- name: Authenticate with Registry
run: |
echo "registry=http://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: build
run: pnpm build
- name: release package
if: ${{ success() && github.ref == 'refs/heads/main' && github.event_name == 'push' }}
run: pnpm release --dry-run
run: pnpm release --npm.skipChecks --increment 1.0.0
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_REGISTRY: https://registry.npmjs.org/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# FRSOURCE Tooling
# FRSOURCE Toolkit

A repository that holds configuration files for tooling used throughout the FRSOURCE organization.
A repository that holds shared toolkit used throughout the FRSOURCE organization:

- configuration files,
- GitHub Actions scripts.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"pnpm": ">=8.7.6"
},
"scripts": {
"release": "pnpm run -r release"
"release": "pnpm run -r release --workspace-concurrency=1"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { name } = require("./package.json");
const { monorepoIndependent } = require("@frsource/release-it-config");

module.exports = monorepoIndependent({
name: "eslint-config",
pkgName: name,
buildCmd: "", // no build needed
});
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@frsource/eslint-config",
"version": "1.0.0",
"version": "0.0.0",
"main": "index.mjs",
"type": "module",
"scripts": {
Expand All @@ -18,13 +18,14 @@
"peerDependencies": {
"eslint": ">= 9"
},
"homepage": "https://github.com/FRSOURCE/tooling/",
"homepage": "https://github.com/FRSOURCE/toolkit/",
"repository": {
"type": "git",
"url": "git+https://github.com/FRSOURCE/tooling.git"
"url": "git+https://github.com/FRSOURCE/toolkit.git",
"directory": "packages/eslint"
},
"bugs": {
"url": "https://github.com/FRSOURCE/tooling/issues"
"url": "https://github.com/FRSOURCE/toolkit/issues"
},
"author": "Jakub Freisler <[email protected]>",
"license": "MIT",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { name } = require("./package.json");
const { monorepoIndependent } = require("@frsource/release-it-config");

module.exports = monorepoIndependent({
name: "prettier-config",
pkgName: name,
buildCmd: "", // no build needed
});
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@frsource/prettier-config",
"version": "1.0.0",
"version": "0.0.0",
"main": "index.mjs",
"type": "module",
"scripts": {
Expand All @@ -18,13 +18,14 @@
"peerDependencies": {
"eslint": ">= 9"
},
"homepage": "https://github.com/FRSOURCE/tooling/",
"homepage": "https://github.com/FRSOURCE/toolkit/",
"repository": {
"type": "git",
"url": "git+https://github.com/FRSOURCE/tooling.git"
"url": "git+https://github.com/FRSOURCE/toolkit.git",
"directory": "packages/prettier-config"
},
"bugs": {
"url": "https://github.com/FRSOURCE/tooling/issues"
"url": "https://github.com/FRSOURCE/toolkit/issues"
},
"author": "Jakub Freisler <[email protected]>",
"license": "MIT",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { name } = require("./package.json");
const { monorepoIndependent } = require("./index.cjs");

module.exports = monorepoIndependent({
name: "release-it",
pkgName: name,
buildCmd: "", // no build needed
});
File renamed without changes.
66 changes: 66 additions & 0 deletions packages/release-it-config/monorepoIndependent.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const nodePath = require("path");

/**
* Configuration for independent package in monorepo workspace
* @param {Object} options
* @param {string} options.pkgName name of the package in the monorepo, e.g. `@frsource/my-package`
* @param {string} [options.path=`packages/${options.pkgName}`] path of the package relative to the monorepo root, without starting slash. Always use "/" as delimiter. Will default to `packages/${options.pkgName}` (package scope in `options.pkgName` will be omitted)
* @param {string} [options.buildCmd="pnpm build"] command that should be used to build the package, defaults to `pnpm build`
*/
module.exports = ({
pkgName,
path = `packages/${pkgName.substring(pkgName.lastIndexOf("/") + 1)}`,
buildCmd = "pnpm build",
}) => {
if (path.startsWith("/")) path = path.substring(1);
const nestingLevel = path.split("/").length;
if (nodePath.sep !== "/") path = path.replaceAll("/", nodePath.sep);

return {
npm: {
publishPath: "package-pack.tgz",
publish: false,
versionArgs: ["--allow-same-version"],
},
git: {
requireBranch: "main",
requireCommits: true,
requireCommitsFail: false, // if there are no new commits release-it will stop the release process, but without throwing and error
requireCleanWorkingDir: true,
commitsPath: ".",
commitMessage: "chore(release): ${npm.name} v${version}",
tagName: "${npm.name}-v${version}",
tagMatch: "${npm.name}-v[0-9]*.[0-9]*.[0-9]*",
getLatestTagFromAllRefs: false, // https://github.com/release-it/release-it/blob/main/docs/git.md#use-all-refs-to-determine-latest-tag
},
github: {
release: true,
releaseName: `${pkgName}@\${version}`,
comments: {
submit: false, // hitting the secondary rate limit issues, see:
// https://github.com/FRSOURCE/toolkit/actions/runs/8730568392/job/23954615077#step:8:38
issue:
":rocket: _This issue has been resolved in [${releaseName} (click for release notes)](${releaseUrl})._",
pr: ":rocket: _This pull request is included in [${releaseName} (click for release notes)](${releaseUrl})._",
},
},
plugins: {
"@release-it/conventional-changelog": {
gitRawCommitsOpts: {
path,
},
preset: "angular",
infile: "CHANGELOG.md",
},
},
hooks: {
"before:bump": buildCmd,
"after:bump": [
"pnpm install",
`git add ${"../".repeat(nestingLevel)}pnpm-lock.yaml`,
],
// "before:npm:release": "mv $(pnpm pack) package-pack.tgz",
// "after:npm:release": "rm package-pack.tgz",
},
};
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"name": "@frsource/release-it-config",
"version": "1.0.0",
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
"version": "0.0.0",
"main": "index.cjs",
"type": "module",
"scripts": {
"release": "release-it"
},
"dependencies": {
"@release-it/bumper": "^6.0.1",
"@release-it/conventional-changelog": "^8.0.1"
},
"devDependencies": {
Expand All @@ -17,13 +15,14 @@
"peerDependencies": {
"release-it": ">= 17"
},
"homepage": "https://github.com/FRSOURCE/tooling/",
"homepage": "https://github.com/FRSOURCE/toolkit/",
"repository": {
"type": "git",
"url": "git+https://github.com/FRSOURCE/tooling.git"
"url": "git+https://github.com/FRSOURCE/toolkit.git",
"directory": "packages/release-it-config"
},
"bugs": {
"url": "https://github.com/FRSOURCE/tooling/issues"
"url": "https://github.com/FRSOURCE/toolkit/issues"
},
"author": "Jakub Freisler <[email protected]>",
"license": "MIT",
Expand Down
38 changes: 0 additions & 38 deletions packages/release-it/monorepoIndependent.cjs

This file was deleted.

Loading

0 comments on commit f150146

Please sign in to comment.