Skip to content

Commit

Permalink
chore(ci): next-release
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge committed Aug 15, 2022
1 parent cb61f26 commit e5e3fca
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/version-script.js → .github/version-script-beta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// https://github.com/cloudflare/wrangler2/blob/main/.github/version-script.js
import fs from "fs";
import { exec } from "child_process";
import { getT3Version } from "../src/utils/getT3Version";

try {
const pkg = JSON.parse(fs.readFileSync("package.json"));
Expand All @@ -10,8 +11,8 @@ try {
console.log(err);
process.exit(1);
}
// Version has to supersede the currently available version
pkg.version = "5.5.0-" + stdout.trim();
const currentVersion = getT3Version();
pkg.version = currentVersion + "-beta." + stdout.trim();
fs.writeFileSync("package.json", JSON.stringify(pkg, null, "\t") + "\n");
});
} catch (error) {
Expand Down
21 changes: 21 additions & 0 deletions .github/version-script-next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ORIGINALLY FROM CLOUDFLARE WRANGLER:
// https://github.com/cloudflare/wrangler2/blob/main/.github/version-script.js
import fs from "fs";
import { exec } from "child_process";
import { getT3Version } from "../src/utils/getT3Version";

try {
const pkg = JSON.parse(fs.readFileSync("package.json"));
exec("git rev-parse --short HEAD", (err, stdout) => {
if (err) {
console.log(err);
process.exit(1);
}
const currentVersion = getT3Version();
pkg.version = currentVersion + "-next." + stdout.trim();
fs.writeFileSync("package.json", JSON.stringify(pkg, null, "\t") + "\n");
});
} catch (error) {
console.error(error);
process.exit(1);
}
45 changes: 45 additions & 0 deletions .github/workflows/nextrelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Originally inspired by Cloudflare Wrangler
# https://github.com/cloudflare/wrangler2/blob/main/.github/workflows/prereleases.yml

name: Prerelease

on:
push:
branches:
- next
jobs:
prerelease:
if: ${{ github.repository_owner == 't3-oss' }}
name: Build & Publish a next release to NPM
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Use PNPM
uses: pnpm/action-setup@v2.2.2
with:
version: 7.2.1

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: "pnpm"

- name: Install NPM Dependencies
run: pnpm install

- name: Modify package.json version
run: node .github/version-script-next.js

- name: Authenticate to NPM
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_ACCESS_TOKEN }}" > .npmrc

- name: Publish Beta to NPM
run: pnpm pub:next
env:
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
5 changes: 4 additions & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Originally inspired by Cloudflare Wrangler
# https://github.com/cloudflare/wrangler2/blob/main/.github/workflows/prereleases.yml

name: Prerelease

on:
Expand Down Expand Up @@ -31,7 +34,7 @@ jobs:
run: pnpm install

- name: Modify package.json version
run: node .github/version-script.js
run: node .github/version-script-beta.js

- name: Authenticate to NPM
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_ACCESS_TOKEN }}" > .npmrc
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
"check": "pnpm lint && pnpm format:check && pnpm typecheck",
"prepare": "husky install",
"release": "changeset version",
"pub:beta": "npm run build && npm publish --tag beta",
"pub:release": "npm run build && npm publish"
"pub:beta": "pnpm build && npm publish --tag beta",
"pub:next": "pnpm build && npm publish --tag next",
"pub:release": "pnpm build && npm publish"
},
"dependencies": {
"chalk": "5.0.1",
Expand Down

0 comments on commit e5e3fca

Please sign in to comment.