-
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 (#118)
* Switch to Changesets-based release process * Bump version * drop unused variable * Update .github/workflows/version-or-publish.yml Co-authored-by: Nicola Molinari <[email protected]> * 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 <[email protected]> * build the action before trying to use it the workflow * Add changeset and actually setup Changesets, lol Co-authored-by: Nicola Molinari <[email protected]>
- Loading branch information
Showing
13 changed files
with
448 additions
and
1,119 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,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
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,13 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": [ | ||
"@changesets/changelog-github", | ||
{ "repo": "changesets/action" } | ||
], | ||
"commit": false, | ||
"linked": [], | ||
"access": "restricted", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
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,5 @@ | ||
--- | ||
"@changesets/action": major | ||
--- | ||
|
||
From now on this action will be released using the Changesets-based workflow (using itself). Thanks to that we'll have a good release history. The users will be able to find specific versions of the action and will be able to track changes over time. It also improves the security as the build artifact will always get built in the CI environment, using a frozen lockfile. |
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,33 @@ | ||
name: Version or Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
changesets: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js 14 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
|
||
- name: Install Dependencies | ||
run: yarn --frozen-lockfile | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Create Release Pull Request or Publish | ||
id: changesets | ||
uses: . | ||
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 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 @@ | ||
# @changesets/action |
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,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}`, | ||
]); | ||
})(); |
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( | ||
/changesets\/action@[^\s]+/g, | ||
`changesets/action@${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
Oops, something went wrong.