mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Switch to Changesets-based release process (#118)
* Switch to Changesets-based release process * Bump version * drop unused variable * Update .github/workflows/version-or-publish.yml Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com> * Push also to a release line branch when releasing * Change node version used in the version-or-publish workflow * Switch to using the local action Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com> * build the action before trying to use it the workflow * Add changeset and actually setup Changesets, lol Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com>
This commit is contained in:
co-authored by
Nicola Molinari
parent
21240c3cd1
commit
05c863d3f9
@@ -0,0 +1,41 @@
|
||||
const path = require("path");
|
||||
const { exec, getExecOutput } = require("@actions/exec");
|
||||
|
||||
const { version } = require("../package.json");
|
||||
const tag = `v${version}`;
|
||||
const releaseLine = `v${version.split(".")[0]}`;
|
||||
|
||||
process.chdir(path.join(__dirname, ".."));
|
||||
|
||||
(async () => {
|
||||
const { exitCode, stderr } = await getExecOutput(
|
||||
`git`,
|
||||
["ls-remote", "--exit-code", "origin", "--tags", `refs/tags/${tag}`],
|
||||
{
|
||||
ignoreReturnCode: true,
|
||||
}
|
||||
);
|
||||
if (exitCode === 0) {
|
||||
console.log(
|
||||
`Action is not being published because version ${tag} is already published`
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (exitCode !== 2) {
|
||||
throw new Error(`git ls-remote exited with ${exitCode}:\n${stderr}`);
|
||||
}
|
||||
|
||||
await exec("git", ["checkout", "--detach"]);
|
||||
await exec("git", ["add", "--force", "dist"]);
|
||||
await exec("git", ["commit", "-m", tag]);
|
||||
|
||||
await exec("changeset", ["tag"]);
|
||||
|
||||
await exec("git", [
|
||||
"push",
|
||||
"--force",
|
||||
"--follow-tags",
|
||||
"origin",
|
||||
`HEAD:refs/heads/${releaseLine}`,
|
||||
]);
|
||||
})();
|
||||
Reference in New Issue
Block a user