Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
18 changes: 18 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "apollo-server-integrations/apollo-server-integration-google-cloud-functions" }
],
"commit": false,
"updateInternalDependencies": "patch",
"access": "public",
"baseBranch": "main",
"fixed": [["@as-integrations/google-cloud-functions"]],
"ignore": ["apollo-server-integration-google-cloud-functions-example"],
"changedFilePatterns": ["src/**"],
"snapshot": {
"useCalculatedVersion": true,
"prereleaseTemplate": "{tag}.{commit}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker - but if you wanted to release a normal alpha, rc, etc, you'd be stuck with the commit hash on the version as well?

}
}
28 changes: 28 additions & 0 deletions .github/canary-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import fs from 'fs';
import { exec } from 'child_process';

const pkgJsonPaths = ['cli/package.json'];

try {
exec('git rev-parse --short HEAD', (err, stdout) => {
if (err) {
console.log(err);
process.exit(1);
}
const commitHash = stdout.trim();

for (const pkgJsonPath of pkgJsonPaths) {
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
const oldVersion = pkg.version;
const [major, minor, patch] = oldVersion.split('.').map(Number);
const newVersion = `${major}.${minor}.${patch + 1}-canary.${commitHash}`;
pkg.version = newVersion;
const content = JSON.stringify(pkg, null, '\t') + '\n';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never actually seen a \t used here, typically it's a 2. I guess this depends on if the project uses tabs or spaces? Haven't thought about that in a long time :)

Suggested change
const content = JSON.stringify(pkg, null, '\t') + '\n';
const content = JSON.stringify(pkg, null, 2) + '\n';


fs.writeFileSync(pkgJsonPath, content);
}
});
} catch (error) {
console.error(error);
process.exit(1);
}
11 changes: 11 additions & 0 deletions .github/changeset-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// ORIGINALLY FROM CLOUDFLARE WRANGLER:
// https://github.com/cloudflare/wrangler2/blob/main/.github/changeset-version.js

import { exec } from 'child_process';
// This script is used by the `release.yml` workflow to update the version of the packages being released.
// The standard step is only to run `changeset version` but this does not update the package-lock.json file.
// So we also run `npm install`, which does this update.
// This is a workaround until this is handled automatically by `changeset version`.
// See https://github.com/changesets/changesets/issues/421.
exec('npx changeset version');
exec('npm install');
Comment on lines +1 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be an npm script, fine as is too. We do the same thing in Apollo Server.

65 changes: 65 additions & 0 deletions .github/workflows/release-canary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Release Canary
on:
push:
branches:
- canary

permissions:
id-token: write

jobs:
release-canary:
if: ${{ github.repository_owner == 'apollo-server-integrations' }}
name: Release Canary
runs-on: ubuntu-latest
outputs:
releaseId: ${{ steps.release-id.outputs.releaseId }}

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

- name: Use PNPM
uses: pnpm/[email protected]

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install deps (with cache)
run: pnpm install

- name: Build
run: pnpm build

## The change made to package.json here is ephemeral, as it will only run in CI
- name: Bump version to canary
run: node .github/canary-release.js

- name: Install NPM
run: npm i -g [email protected] # need latest version for provenance

- name: Authenticate to npm and publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
pnpm build
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
cd ./package
npm publish --provenance --access public --ignore-scripts --tag canary
88 changes: 38 additions & 50 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,68 +1,56 @@
name: Release
on:
push:
branches:
- main
name: release

jobs:
release-pr:
release:
if: ${{ github.repository_owner == 'apollo-server-integrations' }}
name: Release
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
- name: Checkout
uses: actions/checkout@v3
with:
release-type: node
token: ${{ secrets.RELEASE_PR_TOKEN }}
changelog-types: |-
[
{ "type": "feat", "section": "🔖 Features", "hidden": false },
{ "type": "fix", "section": "🐛 Bug Fixes", "hidden": false },
{ "type": "chore", "section": "🧹 Miscellaneous", "hidden": false }
]
fetch-depth: 0

- name: Use PNPM
uses: pnpm/[email protected]

# Format changelog, workaround for https://github.com/google-github-actions/release-please-action/issues/542
# Taken from https://github.com/remarkablemark/release-please-extra-files-demo/blob/master/.github/workflows/release-please.yml
- uses: actions/checkout@v3
if: ${{ steps.release.outputs.pr }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
ref: ${{ fromJson(steps.release.outputs.pr).headBranchName }}
node-version: 18

- name: Configure Git user
if: ${{ steps.release.outputs.pr }}
- name: Get pnpm store directory
id: pnpm-cache
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git --no-pager show --name-only
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Format CHANGELOG.md
if: ${{ steps.release.outputs.pr }}
run: npx prettier --write CHANGELOG.md
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Commit and push
if: ${{ steps.release.outputs.pr }}
run: |
git add CHANGELOG.md
git commit -m 'chore: Format CHANGELOG.md with Prettier' --no-verify
git push
- name: Install deps (with cache)
run: pnpm install

publish_npm:
name: Publish to npm
runs-on: ubuntu-latest
needs: [release-pr]
if: needs.release-pr.outputs.release_created
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
- name: Build
run: pnpm build

- name: Create Version PR or Publish to NPM
id: changeset
uses: changesets/action@v1
with:
node-version: 16
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Config npm
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
commit: 'chore(release): version packages'
title: 'chore(release): version packages'
version: 'node .github/changeset-version.js'
publish: npx changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
run: pnpm publish --access public --no-git-checks
NODE_ENV: 'production'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"email": "[email protected]"
},
"dependencies": {
"@changesets/cli": "^2.26.2",
"prettier": "^2.8.8",
"turbo": "^1.10.12",
"typescript": "^5.1.6"
Expand Down
Loading