semantic-release-pub 0.10.0 → 0.10.1

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/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.1",
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",