Skip to content

Instantly share code, notes, and snippets.

@baruchiro
Last active March 16, 2022 12:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baruchiro/3a52a9897556a880b32f74f03caca299 to your computer and use it in GitHub Desktop.
Save baruchiro/3a52a9897556a880b32f74f03caca299 to your computer and use it in GitHub Desktop.
name: PR Title
on:
pull_request:
types: [opened, edited, synchronize, reopened]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: deepakputhraya/action-pr-title@3864bebc79c5f829d25dd42d3c6579d040b0ef16
name: Validate PR Title
continue-on-error: true
with:
regex: '\w+:( [\w\.,]+)+( \(\w+ #\d+\))?' # Regex the title should match.
# allowed_prefixes: 'feature,fix,JIRA' # title should start with the given prefix
# disallowed_prefixes: 'feat/,hotfix' # title should not start with the given prefix
# prefix_case_sensitive: false # title prefix are case insensitive
# min_length: 5 # Min length of the title
max_length: 50 # Max length of the title
github_token: ${{ secrets.GITHUB_TOKEN }} # Default: ${{ github.token }}
- uses: mshick/add-pr-comment@07f690343c25a94e24a8acb70d03c86b701ae322
name: Comment on PR
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
Please fix the title of this PR.
Example: `New: Add new feature`
See more in `/docs/RELEASE.md`.
name: Release
on:
pull_request:
push:
branches: master
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lint
- run: yarn test
- run: yarn build
- run: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
- uses: ethomson/send-tweet-action@ee76e315ba1f8fed3444282c3c8be0fbb369c751
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
with:
status: "${{github.repository}} V${{ env.SEMVER_VERSION }} is published!\n\nhttps://www.npmjs.com/package/use-route-as-state\n\n@github #send_tweet_action @npmjs #use_route_as_state @reactjs\n\nAvailable in Github"
consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
const conventionalCommits = {
preset: 'eslint'
}
module.exports = {
release: {
branches: ["master"]
},
plugins: [
[
'@semantic-release/commit-analyzer',
conventionalCommits
],
[
'@semantic-release/release-notes-generator',
conventionalCommits
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"assets": ["CHANGELOG.md"],
"message": "${nextRelease.version} CHANGELOG [skip ci]\n\n${nextRelease.notes}"
}
],
'@semantic-release/npm',
'@semantic-release/github',
[
"@semantic-release/exec",
{
"successCmd": "echo \"SEMVER_VERSION=${nextRelease.version}\" > $GITHUB_ENV"
}
]
]
}

Release

I'm using semantic-release to perform releases and changelog.

The convention is the eslint format, with the next rules:

{tag: 'Breaking', release: 'major'},
{tag: 'Fix', release: 'patch'},
{tag: 'Update', release: 'minor'},
{tag: 'New', release: 'minor'},

When you commiting something, you don't have to keep the convention, but let's say in the PR, squash (prefer don't merge) and update the squash message with these examples:

Breaking: I broke something
Fix: fix (fixes #1234)
Update: some packages updates (refs #123)
New: Added a new feature

I think the refs should be the PR itself, since these messages generated in the Changelog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment