-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to Changesets-based release process
- Loading branch information
Showing
7 changed files
with
351 additions
and
1,113 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,30 @@ | ||
name: Version or Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
changesets: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@master | ||
|
||
- name: Setup Node.js 12.x | ||
uses: actions/setup-node@master | ||
with: | ||
node-version: 12.x | ||
|
||
- name: Install Dependencies | ||
run: yarn | ||
|
||
- name: Create Release Pull Request or Publish | ||
id: changesets | ||
uses: changesets/action@master | ||
with: | ||
version: yarn version | ||
publish: yarn 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_modules | ||
.parcel-cache | ||
.cache | ||
*.log | ||
*.log | ||
|
||
dist/ |
This file was deleted.
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
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,35 @@ | ||
const path = require("path"); | ||
const { exec, getExecOutput } = require("@actions/exec"); | ||
const tag = `v${require("../package.json").version}`; | ||
|
||
process.chdir(path.join(__dirname, "..")); | ||
|
||
(async () => { | ||
const { exitCode, stderr } = await getExecOutput( | ||
`git`, | ||
["ls-remote", "--exit-code", "origin", "--tags", `refs/tags/${tag}`], | ||
{ | ||
ignoreReturnCode: true, | ||
} | ||
); | ||
const exists = stdout.trim() !== ""; | ||
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("yarn", ["build"]); | ||
|
||
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", "origin", tag]); | ||
})(); |
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 tag = `v${require("../package.json").version}`; | ||
|
||
const readmePath = path.join(__dirname, "..", "README.md"); | ||
const content = fs.readFileSync(readmePath, "utf8"); | ||
const updatedContent = content.replace( | ||
/changesets\/action@[^\s]+/g, | ||
`changesets/action@${tag}` | ||
); | ||
fs.writeFileSync(readmePath, updatedContent); | ||
})(); |
Oops, something went wrong.