mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Introduce an option to use the GitHub API to commit changes, for GPG (#391)
* Create tags on GitHub using API To allow for signed tags to be created, rather than use the git CLI to push tags, manually push each tag using the GitHub API, which will sign the tag using the built-in GitHub GPG key. * Use ghcommit to push changes To allow for all commits to be signed, use the GitHub API to push changes. * Add changeset version * Allow tag publish to fail, assume it was manually published * Add to changeset * Update @s0/ghcommit * Update ghcommit to fix missing ref bug * Make using GitHub API Optional Change this to a minor version bump, with a new feature that allows for using the GitHub API to create tags and commits. * Use a strategy pattern for GitHub API vs CLI usage * refactor git interactions * fix mock thing * usechangesets pkg * switch to `commitMode` --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This commit is contained in:
co-authored by
Mateusz Burzyński
parent
bd5d1d2a62
commit
207dc3da2d
+26
-20
@@ -1,10 +1,10 @@
|
||||
import { Changeset } from "@changesets/types";
|
||||
import writeChangeset from "@changesets/write";
|
||||
import fixturez from "fixturez";
|
||||
import * as github from "@actions/github";
|
||||
import * as githubUtils from "@actions/github/lib/utils";
|
||||
import fs from "fs-extra";
|
||||
import path from "path";
|
||||
import writeChangeset from "@changesets/write";
|
||||
import { Changeset } from "@changesets/types";
|
||||
import { Git } from "./git";
|
||||
import { setupOctokit } from "./octokit";
|
||||
import { runVersion } from "./run";
|
||||
|
||||
jest.mock("@actions/github", () => ({
|
||||
@@ -18,19 +18,20 @@ jest.mock("@actions/github", () => ({
|
||||
},
|
||||
}));
|
||||
jest.mock("@actions/github/lib/utils", () => ({
|
||||
GitHub: {
|
||||
plugin: () => {
|
||||
// function necessary to be used as constructor
|
||||
return function() {
|
||||
return {
|
||||
rest: mockedGithubMethods,
|
||||
}
|
||||
}
|
||||
},
|
||||
GitHub: {
|
||||
plugin: () => {
|
||||
// function necessary to be used as constructor
|
||||
return function () {
|
||||
return {
|
||||
rest: mockedGithubMethods,
|
||||
};
|
||||
};
|
||||
},
|
||||
getOctokitOptions: jest.fn(),
|
||||
},
|
||||
getOctokitOptions: jest.fn(),
|
||||
}));
|
||||
jest.mock("./gitUtils");
|
||||
jest.mock("./git");
|
||||
jest.mock("@changesets/ghcommit/git");
|
||||
|
||||
let mockedGithubMethods = {
|
||||
pulls: {
|
||||
@@ -89,7 +90,8 @@ describe("version", () => {
|
||||
);
|
||||
|
||||
await runVersion({
|
||||
githubToken: "@@GITHUB_TOKEN",
|
||||
octokit: setupOctokit("@@GITHUB_TOKEN"),
|
||||
git: new Git(),
|
||||
cwd,
|
||||
});
|
||||
|
||||
@@ -122,7 +124,8 @@ describe("version", () => {
|
||||
);
|
||||
|
||||
await runVersion({
|
||||
githubToken: "@@GITHUB_TOKEN",
|
||||
octokit: setupOctokit("@@GITHUB_TOKEN"),
|
||||
git: new Git(),
|
||||
cwd,
|
||||
});
|
||||
|
||||
@@ -155,7 +158,8 @@ describe("version", () => {
|
||||
);
|
||||
|
||||
await runVersion({
|
||||
githubToken: "@@GITHUB_TOKEN",
|
||||
octokit: setupOctokit("@@GITHUB_TOKEN"),
|
||||
git: new Git(),
|
||||
cwd,
|
||||
});
|
||||
|
||||
@@ -208,7 +212,8 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
|
||||
);
|
||||
|
||||
await runVersion({
|
||||
githubToken: "@@GITHUB_TOKEN",
|
||||
octokit: setupOctokit("@@GITHUB_TOKEN"),
|
||||
git: new Git(),
|
||||
cwd,
|
||||
prBodyMaxCharacters: 1000,
|
||||
});
|
||||
@@ -265,7 +270,8 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
|
||||
);
|
||||
|
||||
await runVersion({
|
||||
githubToken: "@@GITHUB_TOKEN",
|
||||
octokit: setupOctokit("@@GITHUB_TOKEN"),
|
||||
git: new Git(),
|
||||
cwd,
|
||||
prBodyMaxCharacters: 500,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user