-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: automate package publishing using semantic-release #68
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3dec8a4
Add automated release
BalbinaK 0500535
docs: add commitizen
BalbinaK b4c8bf1
Update prerelease branch name to alpha
BalbinaK bd3ea44
Add workflow for rebasing alpha after merging it to master
BalbinaK 82a7e7a
Update default release branch name to 'master'
BalbinaK 60c2a1e
Add workflow for validating PR titles
BalbinaK cdec25b
Add names to workflow steps for consistency's sake
BalbinaK 1738b2f
Publish just dist, src and dev.js
BalbinaK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,107 @@ | ||
name: PR Title Checker | ||
|
||
on: | ||
pull_request: | ||
types: ["opened", "edited", "reopened", "synchronize"] | ||
branches: | ||
- '*' | ||
- '*/*' | ||
- '**' | ||
- '!master' | ||
|
||
jobs: | ||
check: | ||
name: Validate PR Title | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: current | ||
- name : Get Title of PR | ||
uses: actions/github-script@v6 | ||
id: pr-title | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
result-encoding: json | ||
script: | | ||
const { data: pr } = await github.rest.issues.get({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
return pr.title; | ||
- name : Test Title of PR | ||
uses: actions/github-script@v6 | ||
id: pr-title-check | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
result-encoding: json | ||
script: | | ||
const prTitle = ${{steps.pr-title.outputs.result}}; | ||
const regex = new RegExp('^(chore|docs|feat|fix|perf|refactor|style|test|build|revert)((.+))?:(.+)'); | ||
return !regex.test(prTitle); | ||
- name: Update PR Comment | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
result-encoding: json | ||
script: | | ||
// Retrieve existing bot comments for the PR | ||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
}); | ||
const botComment = comments.find(comment => { | ||
return comment.user.type === 'Bot' && comment.body.includes('Incorrect Pull Request Title Format') | ||
}); | ||
|
||
if (${{steps.pr-title-check.outputs.result}}) { | ||
const body = `**Incorrect Pull Request Title Format** | ||
The title of this pull request does not appear to match the commit message format. | ||
\`\`\` | ||
Examples from Commitizen | ||
\`\`\` | ||
![](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png) | ||
`; | ||
|
||
// If we have a comment, update it, otherwise create a new one | ||
if (botComment) { | ||
github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: botComment.id, | ||
body | ||
}); | ||
} else { | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body | ||
}); | ||
} | ||
return; | ||
} | ||
if (botComment) { | ||
github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: botComment.id, | ||
body: `:sparkles: **Valid Pull Request Title Format** :sparkles:`, | ||
}); | ||
return; | ||
} | ||
- name: Check PR Title Status | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
result-encoding: json | ||
script: | | ||
const hasError = ${{steps.pr-title-check.outputs.result}}; | ||
if (hasError) { | ||
core.setFailed('PR Title Checker job has failed!'); | ||
} |
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,31 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- alpha | ||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: current | ||
- name: Install pnpm and dependencies | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 7 | ||
run_install: true | ||
- name: Test | ||
run: pnpm test | ||
- name: Build | ||
run: pnpm build | ||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npx semantic-release |
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,20 @@ | ||
name: Update alpha | ||
on: | ||
workflow_run: | ||
workflows: | ||
- Release | ||
branches: | ||
- master | ||
types: completed | ||
jobs: | ||
rebase: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Rebase alpha to master | ||
run: | | ||
git fetch --unshallow | ||
git checkout alpha | ||
git rebase origin/master | ||
git push |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"branches": [{ "name": "master" }, { "name": "alpha", "prerelease": true }], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/changelog", | ||
[ | ||
"@semantic-release/npm", | ||
{ | ||
"tarballDir": "release" | ||
} | ||
], | ||
[ | ||
"@semantic-release/github", | ||
{ | ||
"assets": "release/*.tgz" | ||
} | ||
], | ||
"@semantic-release/git" | ||
] | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been wondering about this... is there a reason why the package is named
uno
and notdrive
? 🤔😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users have no relation to the word
drive
. They're using this package in an UnoCSS context. We don't need to be filling users' heads with "OK I want the Warp Uno preset, was that@warp-ds/drive
or@warp-ds/speed
or the other gimmicky package name they went with?" 😆preset
orpreset-uno
might be an even better name - but it's possible at some point we want to export more than just a preset from this package.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...then my next question is: Why is it called
drive
and notuno
in github? 🤷♂️😅😜 I was a bit confused about this since all other repos is mapped 1:1 between github and npm? (Or at least I think they are? 🤔😄)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically "for the lulz". I agree with your logic, we could have some kind of alias repo to be sure people find the right thing. I'm up for whatever the team feels is best here to aid users understanding our packages and being able to discover things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally reasonable reason. 👌😄