semantic-release-pub 0.10.0 → 0.10.2

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
@@ -54,28 +54,9 @@ The plugin can be configured in the [semantic-release configuration file](https:
54
54
 
55
55
  ### `pub.dev` authentication
56
56
 
57
- You can publish to `pub.dev` using either GitHub Actions OIDC or Google Service Account.
57
+ You can publish to `pub.dev` using either Google Service Account or GitHub Actions OIDC.
58
58
 
59
- #### GitHub Actions OIDC
60
-
61
- The following instructions are referenced from the [documentation](https://dart.dev/tools/pub/automated-publishing#configuring-automated-publishing-from-github-actions-on-pub-dev) of Dart. Below are the key steps to allow authentication to `pub.dev` via GitHub Actions OIDC.
62
-
63
- 1. Enable automated publishing.
64
-
65
- > To complete this step, you must have uploader permission on the package or be an admin of the publisher that owns the package.
66
-
67
- 1. Navigate to the package Admin tab (pub.dev/packages/<package>/admin).
68
- 2. Click Enable publishing from GitHub Actions.
69
- 3. Then fill in the necessary information.
70
-
71
- 2. In your workflow, add the `id-token` permission.
72
-
73
- ```yaml
74
- jobs:
75
- publish:
76
- permissions:
77
- id-token: write
78
- ```
59
+ Note that when using GitHub Actions OIDC, `pub.dev` only allows authentication when the workflow is triggered by a `tag` event. See [here](https://github.com/dart-lang/pub-dev/issues/8507) for more details.
79
60
 
80
61
  #### Google Service Account
81
62
 
@@ -109,6 +90,28 @@ The following instructions are referenced from the [documentation](https://dart.
109
90
 
110
91
  5. Copy the content of the JSON key file and set it as an environment variable under `GOOGLE_SERVICE_ACCOUNT_KEY`.
111
92
 
93
+
94
+ #### GitHub Actions OIDC
95
+
96
+ The following instructions are referenced from the [documentation](https://dart.dev/tools/pub/automated-publishing#configuring-automated-publishing-from-github-actions-on-pub-dev) of Dart. Below are the key steps to allow authentication to `pub.dev` via GitHub Actions OIDC.
97
+
98
+ 1. Enable automated publishing.
99
+
100
+ > To complete this step, you must have uploader permission on the package or be an admin of the publisher that owns the package.
101
+
102
+ 1. Navigate to the package Admin tab (pub.dev/packages/<package>/admin).
103
+ 2. Click Enable publishing from GitHub Actions.
104
+ 3. Then fill in the necessary information.
105
+
106
+ 2. In your workflow, add the `id-token` permission.
107
+
108
+ ```yaml
109
+ jobs:
110
+ publish:
111
+ permissions:
112
+ id-token: write
113
+ ```
114
+
112
115
  ### Environment variables
113
116
 
114
117
  | Variable | Description |
package/dist/publish.js CHANGED
@@ -1,6 +1,5 @@
1
- import core from "@actions/core";
2
1
  import { execa } from "execa";
3
- import { getConfig, getGoogleIdentityToken, getPubspec } from "./utils.js";
2
+ import { getConfig, getGithubIdentityToken, getGoogleIdentityToken, getPubspec, } from "./utils.js";
4
3
  const SEMANTIC_RELEASE_PUB_TOKEN = "SEMANTIC_RELEASE_PUB_TOKEN";
5
4
  export const publish = async (pluginConfig, { nextRelease: { version }, logger }) => {
6
5
  const { cli, publishPub, useGithubOidc } = getConfig(pluginConfig);
@@ -9,7 +8,7 @@ export const publish = async (pluginConfig, { nextRelease: { version }, logger }
9
8
  return;
10
9
  }
11
10
  const pubspec = getPubspec();
12
- const pubToken = await getPubToken(useGithubOidc);
11
+ const pubToken = await getPubToken(useGithubOidc, logger);
13
12
  await setPubToken(cli, pubToken);
14
13
  logger.log(`Publishing version ${version} to pub.dev`);
15
14
  await execa(cli, ["pub", "publish", "--force"]);
@@ -19,10 +18,12 @@ export const publish = async (pluginConfig, { nextRelease: { version }, logger }
19
18
  url: `https://pub.dev/packages/${pubspec.name}/versions/${version}`,
20
19
  };
21
20
  };
22
- const getPubToken = async (useGithubOidc) => {
21
+ const getPubToken = async (useGithubOidc, logger) => {
23
22
  if (useGithubOidc) {
24
- return await core.getIDToken();
23
+ logger.log("Using GitHub OIDC token to publish to pub.dev");
24
+ return await getGithubIdentityToken();
25
25
  }
26
+ logger.log("Using Google identity token to publish to pub.dev");
26
27
  const { GOOGLE_SERVICE_ACCOUNT_KEY } = process.env;
27
28
  return await getGoogleIdentityToken(GOOGLE_SERVICE_ACCOUNT_KEY);
28
29
  };
package/dist/utils.d.ts CHANGED
@@ -2,6 +2,7 @@ import { PluginConfig } from "./types.js";
2
2
  export declare const PUBSPEC_PATH = "pubspec.yaml";
3
3
  export declare const getConfig: (config: PluginConfig) => PluginConfig;
4
4
  export declare const getGoogleIdentityToken: (serviceAccountStr: string) => Promise<string>;
5
+ export declare const getGithubIdentityToken: () => Promise<string>;
5
6
  export declare const getPubspecString: () => string;
6
7
  export declare const getPubspecFromString: (data: string) => {
7
8
  name?: string;
package/dist/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import core from "@actions/core";
1
2
  import SemanticReleaseError from "@semantic-release/error";
2
3
  import { readFileSync } from "fs";
3
4
  import { JWT } from "google-auth-library";
@@ -23,6 +24,9 @@ export const getGoogleIdentityToken = async (serviceAccountStr) => {
23
24
  }
24
25
  return creds.id_token;
25
26
  };
27
+ export const getGithubIdentityToken = async () => {
28
+ return core.getIDToken(PUB_DEV_AUDIENCE);
29
+ };
26
30
  export const getPubspecString = () => {
27
31
  return readFileSync(PUBSPEC_PATH, "utf-8");
28
32
  };
@@ -1,7 +1,6 @@
1
- import core from "@actions/core";
2
1
  import SemanticReleaseError from "@semantic-release/error";
3
2
  import { execa } from "execa";
4
- import { getConfig, getGoogleIdentityToken } from "./utils.js";
3
+ import { getConfig, getGithubIdentityToken, getGoogleIdentityToken, } from "./utils.js";
5
4
  export const verifyConditions = async (pluginConfig, { logger }) => {
6
5
  const { cli, publishPub, useGithubOidc } = getConfig(pluginConfig);
7
6
  if (publishPub) {
@@ -15,7 +14,7 @@ export const verifyConditions = async (pluginConfig, { logger }) => {
15
14
  const verifyPublishToken = async (useGithubOidc) => {
16
15
  if (useGithubOidc) {
17
16
  try {
18
- await core.getIDToken();
17
+ await getGithubIdentityToken();
19
18
  }
20
19
  catch (error) {
21
20
  throw new SemanticReleaseError(`Failed to get GitHub OIDC token: ${error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantic-release-pub",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
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
  "format": "ESLINT_USE_FLAT_CONFIG=false eslint --ext .ts --fix src tests && prettier --write src/**/*.ts tests/**/*.ts"
30
30
  },
31
31
  "engines": {
32
- "node": ">=22.13.1"
32
+ "node": ">=22.14.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@actions/core": "^1.11.1",
@@ -37,7 +37,7 @@
37
37
  "execa": "^9.5.2",
38
38
  "google-auth-library": "^9.15.1",
39
39
  "yaml": "^2.7.0",
40
- "zod": "^3.24.1"
40
+ "zod": "^3.24.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@semantic-release/changelog": "6.0.3",
@@ -46,22 +46,22 @@
46
46
  "@types/semantic-release": "20.0.6",
47
47
  "@types/semantic-release__error": "3.0.3",
48
48
  "@types/signale": "1.4.7",
49
- "@typescript-eslint/eslint-plugin": "8.21.0",
50
- "@typescript-eslint/parser": "8.21.0",
51
- "@vitest/coverage-v8": "3.0.4",
49
+ "@typescript-eslint/eslint-plugin": "8.24.0",
50
+ "@typescript-eslint/parser": "8.24.0",
51
+ "@vitest/coverage-v8": "3.0.5",
52
52
  "common-tags": "1.8.2",
53
53
  "conventional-changelog-conventionalcommits": "8.0.0",
54
- "eslint": "9.19.0",
54
+ "eslint": "9.20.1",
55
55
  "eslint-config-prettier": "^10.0.1",
56
56
  "eslint-config-semistandard": "17.0.0",
57
57
  "eslint-config-standard": "17.1.0",
58
58
  "eslint-plugin-import": "2.31.0",
59
59
  "eslint-plugin-n": "17.15.1",
60
60
  "eslint-plugin-promise": "7.2.1",
61
- "prettier": "3.4.2",
62
- "semantic-release": "24.2.1",
61
+ "prettier": "3.5.0",
62
+ "semantic-release": "24.2.2",
63
63
  "typescript": "5.7.3",
64
- "vitest": "3.0.4",
64
+ "vitest": "3.0.5",
65
65
  "vitest-mock-extended": "2.0.2"
66
66
  }
67
67
  }