Skip to content

Commit 6a0d649

Browse files
committed
chore: Add edge release
1 parent 02b9a01 commit 6a0d649

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

.github/workflows/release-pr.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
env:
12+
# 7 GiB by default on GitHub, setting to 6 GiB
13+
NODE_OPTIONS: --max-old-space-size=6144
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
release-pr:
20+
permissions:
21+
id-token: write
22+
pull-requests: write
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 20
25+
26+
steps:
27+
- run: corepack enable
28+
- uses: actions/setup-node@3.7.0
29+
with:
30+
node-version: 20
31+
cache: "pnpm"
32+
33+
- name: Install dependencies
34+
run: pnpm install
35+
36+
- name: Build
37+
run: pnpm build
38+
39+
- name: Release Edge
40+
if: |
41+
github.event_name == 'push' &&
42+
!contains(github.event.head_commit.message, '[skip-release]')
43+
run: ./scripts/release-edge.sh pr-${{ github.event.issue.number }}
44+
env:
45+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
46+
NPM_CONFIG_PROVENANCE: true

scripts/bump-edge.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { execSync } from 'node:child_process'
2+
import { inc } from 'semver'
3+
import { consola } from 'consola'
4+
import { determineBumpType, loadWorkspace } from './_utils'
5+
6+
const nightlyPackages = {
7+
nitropack: 'nitropack-edge',
8+
h3: 'h3-nightly',
9+
nuxi: 'nuxi-edge'
10+
}
11+
12+
async function main () {
13+
const workspace = await loadWorkspace(process.cwd())
14+
15+
const commit = execSync('git rev-parse --short HEAD').toString('utf-8').trim().slice(0, 8)
16+
const date = Math.round(Date.now() / (1000 * 60))
17+
18+
const bumpType = await determineBumpType()
19+
20+
for (const pkg of workspace.packages.filter(p => !p.data.private)) {
21+
const newVersion = inc(pkg.data.version, bumpType || 'patch')
22+
workspace.setVersion(pkg.data.name, `${newVersion}-${date}.${commit}`, {
23+
updateDeps: true
24+
})
25+
for (const [name, nightlyName] of Object.entries(nightlyPackages)) {
26+
if (pkg.data.dependencies && name in pkg.data.dependencies) {
27+
pkg.data.dependencies[name] = `npm:${nightlyName}@latest`
28+
}
29+
}
30+
const newname = pkg.data.name + '-edge'
31+
workspace.rename(pkg.data.name, newname)
32+
}
33+
34+
await workspace.save()
35+
}
36+
37+
main().catch((err) => {
38+
consola.error(err)
39+
process.exit(1)
40+
})

scripts/release-edge.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -xe
4+
5+
# Restore all git changes
6+
git restore -s@ -SW -- packages examples
7+
8+
TAG=${1:-latest}
9+
10+
# Bump versions to edge
11+
pnpm jiti ./scripts/bump-edge
12+
13+
# Update token
14+
if [[ ! -z ${NODE_AUTH_TOKEN} ]] ; then
15+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
16+
echo "registry=https://registry.npmjs.org/" >> ~/.npmrc
17+
echo "always-auth=true" >> ~/.npmrc
18+
npm whoami
19+
fi
20+
21+
# Release packages
22+
for p in packages/* ; do
23+
if [[ $p == "packages/nuxt" ]] ; then
24+
continue
25+
fi
26+
pushd $p
27+
echo "Publishing $p"
28+
cp ../../LICENSE .
29+
cp ../../README.md .
30+
pnpm publish --access public --no-git-checks --tag $TAG
31+
popd
32+
done

0 commit comments

Comments
 (0)