Skip to content
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

semantic-release optims #1545

Merged
merged 1 commit into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 6 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,14 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Install deps
# this runs a build script so there is no dedicated build
run: yarn install
- name: Run storybook build script
run: yarn build-storybook
release:
needs: main
runs-on: ubuntu-latest
if: ${{ github.repository == 'pmndrs/drei' && contains('refs/heads/master,refs/heads/beta,refs/heads/alpha',github.ref) && github.event_name == 'push' }}
Copy link
Member Author

@abernier abernier Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is actually no need to check:

  • contains('refs/heads/master,refs/heads/beta,refs/heads/alpha',github.ref) because semantic-release won't release any branch that is not declared in release.config.js.branches
  • github.event_name == 'push' because semantic-release will always ignore PR:

    This run was triggered by a pull request and therefore a new version won't be published.

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Install deps
# this runs a build script so there is no dedicated build
run: yarn install
- name: 🚀 Release
uses: cycjimmy/semantic-release-action@v3
with:
extra_plugins: |
@semantic-release/git
branches: |
[
'master',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
]
Comment on lines -44 to -54
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced this by local semantic-release devDependencies package

- run: yarn install
- run: yarn build-storybook
# semantic-release skips not configured branches(see: release.config.js) or pull-requests
Copy link
Member Author

@abernier abernier Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can securely execute yarn release here, because semantic-release will not make a release for PRs or not configured pushed-branches: this simplifies the workflow a lot, and removes the whole release job, since it is now the same as the one for PRs

- run: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"typegen": "tsc --emitDeclarationOnly",
"storybook": "NODE_OPTIONS=\"--openssl-legacy-provider\" storybook dev -p 6006",
"build-storybook": "NODE_OPTIONS=\"--openssl-legacy-provider\" storybook build",
"copy": "copyfiles package.json README.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.husky=undefined; this.prettier=undefined; this.jest=undefined; this['lint-staged']=undefined;\""
"copy": "copyfiles package.json README.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.husky=undefined; this.prettier=undefined; this.jest=undefined; this['lint-staged']=undefined;\"",
"release": "semantic-release"
},
"dependencies": {
"@babel/runtime": "^7.11.2",
Expand Down Expand Up @@ -129,6 +130,7 @@
"rollup": "^3.25.1",
"rollup-plugin-glslify": "^1.3.0",
"rollup-plugin-multi-input": "^1.4.1",
"semantic-release": "^21.0.6",
"storybook": "^7.0.12",
"three": "^0.149.0",
"ts-node": "^10.9.1",
Expand Down
8 changes: 1 addition & 7 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
branches: ['master', { name: 'alpha', prerelease: true }, { name: 'beta', prerelease: true }],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
Expand All @@ -9,12 +10,5 @@ module.exports = {
},
],
'@semantic-release/github',
[
Copy link
Member Author

@abernier abernier Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we actually do not use that plugin, since we do not want package.json's version to be committed back into the repository:

"version": "0.0.0-semantic-release",

because it is handled by semantic-release on its own: https://semantic-release.gitbook.io/semantic-release/support/faq#why-is-the-package.jsons-version-not-updated-in-my-repository and there is no need for

'@semantic-release/git',
{
assets: ['package.json'],
message: 'chore(release): ${nextRelease.version}',
},
],
],
}
Loading