11import { Buffer } from "node:buffer" ;
22import path from "node:path" ;
3- import { exec , getExecOutput } from "@actions/exec" ;
3+ import { exec } from "@actions/exec" ;
44import pkgJson from "../package.json" with { type : "json" } ;
55
66const tag = `v${ pkgJson . version } ` ;
@@ -20,37 +20,17 @@ const gitEnv = {
2020
2121process . chdir ( path . join ( import . meta. dirname , ".." ) ) ;
2222
23- ( async ( ) => {
24- const { exitCode, stderr } = await getExecOutput (
25- `git` ,
26- [ "ls-remote" , "--exit-code" , "origin" , "--tags" , `refs/tags/${ tag } ` ] ,
27- {
28- ignoreReturnCode : true ,
29- } ,
30- ) ;
31- if ( exitCode === 0 ) {
32- console . log (
33- `Action is not being published because version ${ tag } is already published` ,
34- ) ;
35- return ;
36- }
37- if ( exitCode !== 2 ) {
38- throw new Error ( `git ls-remote exited with ${ exitCode } :\n${ stderr } ` ) ;
39- }
40-
41- await exec ( "git" , [ "checkout" , "--detach" ] ) ;
42- await exec ( "git" , [ "add" , "--force" , "dist" ] ) ;
43- await exec ( "git" , [ "commit" , "-m" , tag ] ) ;
23+ await exec ( "git" , [ "checkout" , "--detach" ] ) ;
24+ await exec ( "git" , [ "add" , "--force" , "dist" ] ) ;
25+ await exec ( "git" , [ "commit" , "-m" , tag ] ) ;
4426
45- await exec ( "changeset" , [ "git-tag" ] ) ;
46-
47- if ( isPrerelease ) {
48- await exec ( "git" , [ "push" , "origin" , `refs/tags/${ tag } ` ] , {
49- env : gitEnv ,
50- } ) ;
51- return ;
52- }
27+ await exec ( "changeset" , [ "git-tag" ] ) ;
5328
29+ if ( isPrerelease ) {
30+ await exec ( "git" , [ "push" , "origin" , `refs/tags/${ tag } ` ] , {
31+ env : gitEnv ,
32+ } ) ;
33+ } else {
5434 await exec (
5535 "git" ,
5636 [
@@ -64,4 +44,4 @@ process.chdir(path.join(import.meta.dirname, ".."));
6444 env : gitEnv ,
6545 } ,
6646 ) ;
67- } ) ( ) ;
47+ }
0 commit comments