Skip to content

Commit 9a00d8c

Browse files
committed
setup ci/cd
1 parent 6a3dc47 commit 9a00d8c

File tree

11 files changed

+1487
-30
lines changed

11 files changed

+1487
-30
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": ["@changesets/changelog-github", { "repo": "cloudflare/workers-oauth-provider" }],
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch"
10+
}

.github/changeset-publish.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { execSync } from 'node:child_process';
2+
3+
execSync('npx changeset publish', {
4+
stdio: 'inherit',
5+
});

.github/changeset-version.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { execSync } from 'node:child_process';
2+
3+
// This script is used by the `release.yml` workflow to update the version of the packages being released.
4+
// The standard step is only to run `changeset version` but this does not update the package-lock.json file.
5+
// So we also run `npm install`, which does this update.
6+
// This is a workaround until this is handled automatically by `changeset version`.
7+
// See https://github.com/changesets/changesets/issues/421.
8+
execSync('npx changeset version', {
9+
stdio: 'inherit',
10+
});
11+
execSync('npm install', {
12+
stdio: 'inherit',
13+
});

.github/version-script.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { execSync } from 'node:child_process';
2+
import * as fs from 'node:fs';
3+
4+
async function main() {
5+
try {
6+
console.log('Getting current git hash...');
7+
const stdout = execSync('git rev-parse --short HEAD').toString();
8+
console.log('Git hash:', stdout.trim());
9+
10+
for (const path of ['./package.json']) {
11+
const packageJson = JSON.parse(fs.readFileSync(path, 'utf-8'));
12+
packageJson.version = `0.0.0-${stdout.trim()}`;
13+
fs.writeFileSync(path, `${JSON.stringify(packageJson, null, 2)}\n`);
14+
}
15+
} catch (error) {
16+
console.error(error);
17+
process.exit(1);
18+
}
19+
}
20+
21+
main().catch((err) => {
22+
// Build failures should fail
23+
console.error(err);
24+
process.exit(1);
25+
});

.github/workflows/prerelease.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Prerelease
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
prerelease:
10+
if: ${{ github.repository_owner == 'cloudflare' }}
11+
timeout-minutes: 5
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 1
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
cache: "npm"
23+
24+
- run: npm install
25+
26+
- name: Modify package.json version
27+
run: npx tsx .github/version-script.ts
28+
29+
- run: npm run build
30+
- run: npm run check
31+
32+
- run: npm publish --tag beta
33+
env:
34+
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
35+

.github/workflows/pullrequest.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Pull Request
2+
3+
on: pull_request
4+
5+
jobs:
6+
check:
7+
timeout-minutes: 5
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 1
13+
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
cache: "npm"
18+
19+
- run: npm install
20+
- run: npm run build
21+
- run: npm run check

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
permissions:
11+
contents: write
12+
13+
if: ${{ github.repository_owner == 'cloudflare' }}
14+
timeout-minutes: 5
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 1
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
cache: "npm"
26+
27+
- run: npm install
28+
- run: npm run build
29+
30+
- id: changesets
31+
uses: changesets/action@v1
32+
with:
33+
version: npx tsx .github/changeset-version.ts
34+
publish: npx tsx .github/changeset-publish.ts
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.WORKERS_OAUTH_PROVIDER_GITHUB_TOKEN }}
37+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
38+
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

.github/workflows/tests.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)