generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50400c2
commit 6401cd9
Showing
6 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Version or Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
changesets: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [16] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/setup-pnpm | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
version: pnpm bump | ||
publish: pnpm release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { exec } = require("@actions/exec"); | ||
|
||
process.chdir(path.join(__dirname, "..")); | ||
|
||
(async () => { | ||
await exec("changeset", ["version"]); | ||
|
||
const releaseLine = `v${require("../package.json").version.split(".")[0]}`; | ||
|
||
const readmePath = path.join(__dirname, "..", "README.md"); | ||
const content = fs.readFileSync(readmePath, "utf8"); | ||
const updatedContent = content.replace( | ||
/kotarella1110\/pr-voyager@[^\s]+/g, | ||
`kotarella1110/pr-voyager@${releaseLine}`, | ||
); | ||
fs.writeFileSync(readmePath, updatedContent); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}`, | ||
]); | ||
})(); |