semantic-release-pub 0.11.18 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -126,6 +126,7 @@ The following instructions are referenced from the [documentation](https://dart.
126
126
  | `publishPub` | Whether to publish the package to the registry. If set to `false`, the `pubspec.yaml` version will still be updated. | `true` |
127
127
  | `updateBuildNumber` | Whether to write build number for every newly bumped version in `pubspec.yaml`. Note that the build number will always be increased by one. Learn more on [Flutter docs](https://docs.flutter.dev/deployment/android#updating-the-apps-version-number). | `false` |
128
128
  | `useGithubOidc` | Whether to use GitHub OIDC. If set to `true`, authentication to `pub.dev` will be done using GitHub OIDC. Otherwise, the `GOOGLE_SERVICE_ACCOUNT_KEY` will be used. | `false` |
129
+ | `pkgRoot` | The path to the package root directory. Useful for monorepos where the package is not at the repository root. | `.` |
129
130
 
130
131
  ### Examples
131
132
 
package/dist/prepare.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { writeFileSync } from "node:fs";
2
2
  import SemanticReleaseError from "@semantic-release/error";
3
- import { getConfig, getPubspecFromString, getPubspecString, PUBSPEC_PATH, } from "./utils.js";
3
+ import { getConfig, getPubspecFromString, getPubspecPath, getPubspecString, } from "./utils.js";
4
4
  export const prepare = async (pluginConfig, { nextRelease: { version }, logger }) => {
5
- const { updateBuildNumber } = getConfig(pluginConfig);
6
- const data = getPubspecString();
5
+ const { updateBuildNumber, pkgRoot } = getConfig(pluginConfig);
6
+ const pubspecPath = getPubspecPath(pkgRoot);
7
+ const data = getPubspecString(pkgRoot);
7
8
  const pubspec = getPubspecFromString(data);
8
9
  const pubspecVersionEscaped = pubspec.version.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&");
9
10
  let nextVersion = version;
@@ -16,6 +17,6 @@ export const prepare = async (pluginConfig, { nextRelease: { version }, logger }
16
17
  nextVersion = `${version}+${buildNumber + 1}`;
17
18
  }
18
19
  const newData = data.replace(new RegExp(`version:[ \t]+['"]?${pubspecVersionEscaped}['"]?`), `version: ${nextVersion}`);
19
- logger.log(`Writing version ${nextVersion} to ${PUBSPEC_PATH}`);
20
- writeFileSync(PUBSPEC_PATH, newData);
20
+ logger.log(`Writing version ${nextVersion} to ${pubspecPath}`);
21
+ writeFileSync(pubspecPath, newData);
21
22
  };
package/dist/publish.js CHANGED
@@ -3,16 +3,16 @@ import { execa } from "execa";
3
3
  import { getConfig, getGithubIdentityToken, getGoogleIdentityToken, getPubspec, } from "./utils.js";
4
4
  const SEMANTIC_RELEASE_PUB_TOKEN = "SEMANTIC_RELEASE_PUB_TOKEN";
5
5
  export const publish = async (pluginConfig, { nextRelease: { version }, logger }) => {
6
- const { cli, publishPub, useGithubOidc } = getConfig(pluginConfig);
6
+ const { cli, publishPub, useGithubOidc, pkgRoot } = getConfig(pluginConfig);
7
7
  if (!publishPub) {
8
8
  logger.log(`Skipping publishing to pub.dev as publishPub is ${publishPub}`);
9
9
  return;
10
10
  }
11
- const pubspec = getPubspec();
11
+ const pubspec = getPubspec(pkgRoot);
12
12
  const pubToken = await getPubToken(useGithubOidc, logger);
13
13
  await setPubToken(cli, pubToken);
14
14
  logger.log(`Publishing version ${version} to pub.dev`);
15
- await execa(cli, ["pub", "publish", "--force"]);
15
+ await execa(cli, ["pub", "publish", "--force"], { cwd: pkgRoot });
16
16
  logger.log(`Published ${pubspec.name}@${version} on pub.dev`);
17
17
  return {
18
18
  name: "pub.dev package",
package/dist/utils.js CHANGED
@@ -1,20 +1,23 @@
1
1
  import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
2
3
  import { getIDToken } from "@actions/core";
3
4
  import SemanticReleaseError from "@semantic-release/error";
4
5
  import { JWT } from "google-auth-library";
5
6
  import { parse } from "yaml";
6
7
  import { Pubspec, ServiceAccount } from "./schemas.js";
7
- export const PUBSPEC_PATH = "pubspec.yaml";
8
+ const PUBSPEC_PATH = "pubspec.yaml";
8
9
  const DEFAULT_CONFIG = {
9
10
  cli: "dart",
10
11
  publishPub: true,
11
12
  updateBuildNumber: false,
12
13
  useGithubOidc: false,
14
+ pkgRoot: ".",
13
15
  };
14
16
  const PUB_DEV_AUDIENCE = "https://pub.dev";
15
17
  export const getConfig = (config) => {
16
18
  return { ...DEFAULT_CONFIG, ...config };
17
19
  };
20
+ export const getPubspecPath = (pkgRoot) => join(pkgRoot, PUBSPEC_PATH);
18
21
  export const getGoogleIdentityToken = async (serviceAccountStr) => {
19
22
  const serviceAccountJson = getServiceAccount(serviceAccountStr);
20
23
  const jwtClient = new JWT({
@@ -31,14 +34,14 @@ export const getGoogleIdentityToken = async (serviceAccountStr) => {
31
34
  export const getGithubIdentityToken = async () => {
32
35
  return getIDToken(PUB_DEV_AUDIENCE);
33
36
  };
34
- export const getPubspecString = () => {
35
- return readFileSync(PUBSPEC_PATH, "utf-8");
37
+ export const getPubspecString = (pkgRoot) => {
38
+ return readFileSync(getPubspecPath(pkgRoot), "utf-8");
36
39
  };
37
40
  export const getPubspecFromString = (data) => {
38
41
  return Pubspec.parse(parse(data));
39
42
  };
40
- export const getPubspec = () => {
41
- const data = getPubspecString();
43
+ export const getPubspec = (pkgRoot) => {
44
+ const data = getPubspecString(pkgRoot);
42
45
  return getPubspecFromString(data);
43
46
  };
44
47
  const getServiceAccount = (serviceAccountStr) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantic-release-pub",
3
- "version": "0.11.18",
3
+ "version": "0.12.0",
4
4
  "description": "semantic-release plugin to publish a Dart or Flutter package",
5
5
  "main": "dist/index.js",
6
6
  "author": "zeshuaro@gmail.com",
@@ -29,7 +29,7 @@
29
29
  "lint:write": "biome check src tests --write"
30
30
  },
31
31
  "engines": {
32
- "node": ">=24.15.0"
32
+ "node": ">=24.16.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@actions/core": "^3.0.1",
@@ -50,12 +50,12 @@
50
50
  "@types/common-tags": "1.8.4",
51
51
  "@types/semantic-release__error": "3.0.3",
52
52
  "@types/signale": "1.4.7",
53
- "@vitest/coverage-v8": "4.1.6",
53
+ "@vitest/coverage-v8": "4.1.7",
54
54
  "common-tags": "1.8.2",
55
55
  "conventional-changelog-conventionalcommits": "9.3.1",
56
56
  "semantic-release": "25.0.3",
57
57
  "typescript": "6.0.3",
58
- "vitest": "4.1.6",
58
+ "vitest": "4.1.7",
59
59
  "vitest-mock-extended": "4.0.0"
60
60
  }
61
61
  }