Skip to content

Commit

Permalink
feat(ci): add release-semver.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 committed Mar 25, 2024
1 parent 6fc0430 commit bb27d40
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ jobs:

- name: Publish(Dry Run)
run: |
node ./scripts/bump-version.js canary
pnpm publish -r --tag ${{ needs.plan.outputs.npm-tag }} --dry-run --no-git-checks
env:
NPM_TOKEN: ${{ secrets.ROLLDOWN_NPM_TOKEN }}
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/release-semver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Release Semver

on:
# Manually released. This will publish under the canary npm tag.
workflow_dispatch:
inputs:
semver:
description: 'The semver release type'
required: true
default: 'patch'
type: choice
options:
- patch # 0.0.1 -> 0.0.2
- minor # 0.0.1 -> 0.1.0
- major # 0.0.1 -> 1.0.0

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
plan:
name: Plan release
runs-on: ubuntu-latest
outputs:
npm-tag: ${{ github.event_name == 'schedule' && 'nightly' || 'canary' }}
steps:
- run: 'echo "Planning release"'

build:
name: Build bindings and node packages
uses: ./.github/workflows/reusable-release-build.yml

publish:
name: Publish npm Packages
runs-on: ubuntu-latest
permissions:
contents: write # for softprops/action-gh-release@v1
id-token: write # for `npm publish --provenance`
needs:
- plan
- build
steps:
- name: Install pnpm
uses: pnpm/action-setup@v3

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install && git reset --hard # fix pnpm install add new line for package.json

- name: Download Binding Artifacts
uses: actions/download-artifact@v4
with:
path: packages/rolldown/artifacts

- name: Move Binding Artifacts
run: pnpm --filter rolldown artifacts

- name: List Rolldown Bindings
run: ls -R ./packages/rolldown/npm
shell: bash

- name: Download Node Artifacts
uses: actions/download-artifact@v4
with:
path: packages/rolldown/dist
name: node-artifact

- name: Copy Licenses
run: |
find ./packages/ -type d -maxdepth 1 -exec cp LICENSE {} \;
find ./packages/ -type d -maxdepth 1 -exec cp THIRD-PARTY-LICENSE {} \;
- name: Set Publishing Config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.ROLLDOWN_NPM_TOKEN }}

- name: Bump version
run: node ./scripts/bump-version.js ${{ inputs.semver }}

- name: Publish(Dry Run)
run: |
pnpm publish -r --tag latest --dry-run --no-git-checks
env:
NPM_TOKEN: ${{ secrets.ROLLDOWN_NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish
run: |
pnpm publish -r --tag latest --no-git-checks
env:
NPM_TOKEN: ${{ secrets.ROLLDOWN_NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
2 changes: 1 addition & 1 deletion packages/rolldown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rolldown",
"version": "0.10.0",
"version": "0.9.0",
"description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
"homepage": "https://rolldown.rs/",
"repository": {
Expand Down
25 changes: 25 additions & 0 deletions scripts/ci/git-push-version-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'zx/globals'
import nodePath from 'node:path'
import nodeAssert from 'node:assert'
import { repoRoot } from '../meta/constants.js'

async function getLastVersion() {
const pkgPath = path.resolve(repoRoot, './packages/rolldown/package.json')
const result = await import(pkgPath, {
assert: {
type: 'json',
},
})
return result.default.version
}

const gitUserName = await $`git config --global user.name`
const gitUserEmail = await $`git config --global user.email`

nodeAssert.equal(gitUserName, 'github-actions[bot]')
nodeAssert.equal(gitUserEmail, 'github-actions[bot]@users.noreply.github.com')

const lastVersion = await getLastVersion()

await $`git tag v${lastVersion} -m "v${lastVersion}"`
await $`git push origin --follow-tags`

0 comments on commit bb27d40

Please sign in to comment.