Skip to content

Commit

Permalink
feat: Setup nightly releases (#579)
Browse files Browse the repository at this point in the history
* Add config.

* Setup nightly.

* Add steps.

* Fixes.

* Fix git.

* Comments.
  • Loading branch information
milesj committed Mar 15, 2024
1 parent b4f5cad commit 14797aa
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
"scripts"
],
"linked": [],
"snapshot": {
"useCalculatedVersion": true
},
"updateInternalDependencies": "minor"
}
75 changes: 57 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
name: Release

on:
# Manually released
workflow_dispatch:
# Every day at midnight (nightly)
schedule:
- cron: '0 0 * * *'
# Uncomment to test in PRs (its safe)
# pull_request:

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

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

build-binding:
strategy:
fail-fast: false
Expand Down Expand Up @@ -114,13 +129,14 @@ jobs:
run: pip install setuptools
if: ${{ matrix.os == 'macos-latest' }}

- name: Install pnpm
uses: pnpm/action-setup@v3

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

- name: Install pnpm
run: corepack enable
cache: pnpm

- name: Install dependencies
run: pnpm install
Expand All @@ -144,13 +160,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3

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

- name: Install pnpm
run: corepack enable
cache: pnpm

- name: Install dependencies
run: pnpm install
Expand All @@ -176,13 +193,14 @@ jobs:
with:
cache-base: main

- name: Install pnpm
uses: pnpm/action-setup@v3

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

- name: Install pnpm
run: corepack enable
cache: pnpm

- name: Install dependencies
run: pnpm install
Expand All @@ -199,6 +217,7 @@ jobs:

test:
needs:
- plan
- build-binding
- build-wasm
- build-node-packages
Expand All @@ -224,13 +243,14 @@ jobs:
with:
submodules: true # Pull submodules for additional files

- name: Install pnpm
uses: pnpm/action-setup@v3

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

- name: Install pnpm
run: corepack enable
cache: pnpm

- name: Install dependencies
run: pnpm install
Expand Down Expand Up @@ -261,23 +281,25 @@ jobs:
run: pnpm test

publish:
name: Publish Npm Packages
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
- test
steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3

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

- name: Install pnpm
run: corepack enable
cache: pnpm

- name: Install dependencies
run: pnpm install && git reset --hard # fix pnpm install add new line for package.json
Expand Down Expand Up @@ -306,11 +328,18 @@ jobs:
path: packages/rolldown/dist
name: node-artifact

- name: Publish
- name: Prepare publish
run: |
find ./packages/ -type d -maxdepth 1 -exec cp LICENSE {} \;
find ./packages/ -type d -maxdepth 1 -exec cp THIRD-PARTY-LICENSE {} \;
echo "//registry.npmjs.org/:_authToken=$ROLLDOWN_NPM_TOKEN" >> ~/.npmrc
echo "//registry.npmjs.org/:_authToken=$ROLLDOWN_NPM_TOKEN" >> ~/.npmrc;
git config --global user.email "github-actions[bot]@users.noreply.github.com";
git config --global user.name "github-actions[bot]";
# Only runs when manually dispatched
- name: Publish
if: ${{ needs.plan.outputs.publish == 'true' }}
run: |
pnpm changeset version
git add --all
git commit -m "chore: Release"
Expand All @@ -319,3 +348,13 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.ROLLDOWN_NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Only runs for nightly
- name: Publish nightly
if: ${{ needs.plan.outputs.nightly == 'true' }}
run: |
pnpm changeset version --snapshot nightly
pnpm changeset publish
env:
NPM_TOKEN: ${{ secrets.ROLLDOWN_NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 14797aa

Please sign in to comment.