Skip to content

Move Schema Stitching #442

Move Schema Stitching

Move Schema Stitching #442

Workflow file for this run

name: Release
on:
push:
branches:
- main
pull_request:
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
dependencies:
if: github.event_name == 'pull_request' && github.event.pull_request.title != 'Upcoming Release Changes'
name: Dependencies
uses: the-guild-org/shared-config/.github/workflows/changesets-dependencies.yml@v1
with:
node-version-file: .node-version
secrets:
githubToken: ${{ secrets.BOT_GITHUB_TOKEN }}
snapshot:
if: github.event_name == 'pull_request'
name: Snapshot
uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@v1
with:
node-version-file: .node-version
npmTag: ${{ github.event.pull_request.title == 'Upcoming Release Changes' && 'rc' || 'alpha' }}
restoreDeletedChangesets: ${{ github.event.pull_request.title == 'Upcoming Release Changes' && true || false }}
secrets:
githubToken: ${{ secrets.BOT_GITHUB_TOKEN }}
npmToken: ${{ secrets.NPM_TOKEN }}
stable:
if: github.ref == 'refs/heads/main'
name: Stable
uses: the-guild-org/shared-config/.github/workflows/release-stable.yml@v1
with:
node-version-file: .node-version
releaseScript: changeset publish
versionScript: changeset version
secrets:
githubToken: ${{ secrets.BOT_GITHUB_TOKEN }}
npmToken: ${{ secrets.NPM_TOKEN }}
ghcr:
name: GitHub Container Registry
runs-on: ubuntu-latest
needs: [stable, snapshot]
if: always() && (
contains(needs.stable.outputs.publishedPackages, '@graphql-hive/gateway') ||
contains(needs.snapshot.outputs.publishedPackages, '@graphql-hive/gateway')
)
steps:
- name: Version
uses: actions/github-script@v7
id: ver-gateway
with:
script: |
const publishedPackages = ${{ needs.stable.outputs.publishedPackages || needs.snapshot.outputs.publishedPackages }};
const gateway = publishedPackages.find((p) => p.name === '@graphql-hive/gateway');
if (!gateway) {
return core.setFailed('@graphql-hive/gateway was not published!');
}
const { version } = gateway;
let r;
if (context.eventName === 'pull_request') {
r = { version, tags: version };
} else {
const [major, minor] = version.split('.');
if (!major || !minor) {
return core.setFailed(`Unknown major or minor in version "${version}"!`);
}
r = { version, tags: `latest,${major},${major}.${minor},${version}` };
}
console.log(r);
return r;
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up env
uses: the-guild-org/shared-config/setup@v1
with:
node-version-file: .node-version
- name: Build
run: yarn build
- name: Bundle
run: yarn workspace @graphql-hive/gateway bundle
- name: Inject version
run: yarn workspace @graphql-hive/gateway tsx scripts/inject-version ${{ fromJSON(steps.ver-gateway.outputs.result).version }}
- name: Bake and Push
uses: docker/bake-action@v5
env:
GATEWAY_TAGS: ${{ fromJSON(steps.ver-gateway.outputs.result).tags }}
with:
targets: gateway
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
push: true
- if: github.event_name == 'pull_request'
name: Comment on PR
uses: marocchino/sticky-pull-request-comment@v2
with:
# match pr comment like with changesets-snapshot-action from the guild's shared-config
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
header: snapshot-release-docker-image
message: |
### 🚀 Snapshot Release (Docker Image)
The latest changes of this PR are available as image on GitHub Container Registry (based on the declared `changesets`):
```
ghcr.io/graphql-hive/gateway:${{ fromJSON(steps.ver-gateway.outputs.result).version }}
```
bin:
name: Binary built on ${{ matrix.os }}
needs: [stable, snapshot]
if: always() && (
contains(needs.stable.outputs.publishedPackages, '@graphql-hive/gateway') ||
contains(needs.snapshot.outputs.publishedPackages, '@graphql-hive/gateway')
)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-14, windows-latest]
steps:
- name: Version
uses: actions/github-script@v7
id: ver-gateway
with:
result-encoding: string
script: |
const publishedPackages = ${{ needs.stable.outputs.publishedPackages || needs.snapshot.outputs.publishedPackages }};
const gateway = publishedPackages.find((p) => p.name === '@graphql-hive/gateway');
if (!gateway) {
return core.setFailed('@graphql-hive/gateway was not published!');
}
const { version } = gateway;
console.log({ version });
return version;
- name: Checkout
uses: actions/checkout@v4
- if: runner.os == 'Windows'
name: Install Windows SDK
uses: fbactions/setup-winsdk@v2
with:
# we want exact version because the signtool path depends on it in package-binary.ts
winsdk-build-version: 18362
- name: Set up env
uses: the-guild-org/shared-config/setup@v1
with:
node-version-file: .node-version
- name: Build
run: yarn build
- name: Bundle
run: yarn workspace @graphql-hive/gateway bundle
- name: Inject version
run: yarn workspace @graphql-hive/gateway tsx scripts/inject-version "${{ steps.ver-gateway.outputs.result }}"
- name: Package binary
run: yarn workspace @graphql-hive/gateway tsx scripts/package-binary
- name: Set binary info
id: binary
run: |
echo "name=hive-gateway-${{ runner.os }}-${{ runner.arch }}${{ runner.os == 'Windows' && '.exe' || ''}}" >> ${{ runner.os == 'Windows' && '$ENV:GITHUB_OUTPUT' || '$GITHUB_OUTPUT' }}
echo "path=packages/gateway/hive-gateway${{ runner.os == 'Windows' && '.exe' || '' }}" >> ${{ runner.os == 'Windows' && '$ENV:GITHUB_OUTPUT' || '$GITHUB_OUTPUT' }}
- if: github.ref == 'refs/heads/main'
name: Compress binary
id: compressed-binary
run: |
gzip -9 ${{ steps.binary.outputs.path }}
echo "name=${{ steps.binary.outputs.name }}.gz" >> ${{ runner.os == 'Windows' && '$ENV:GITHUB_OUTPUT' || '$GITHUB_OUTPUT' }}
echo "path=${{ steps.binary.outputs.path }}.gz" >> ${{ runner.os == 'Windows' && '$ENV:GITHUB_OUTPUT' || '$GITHUB_OUTPUT' }}
- if: github.ref == 'refs/heads/main'
name: Upload release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.BOT_GITHUB_TOKEN }}
tag: hive-gateway@${{ steps.ver-gateway.outputs.result }}
release_name: hive-gateway@${{ steps.ver-gateway.outputs.result }}
asset_name: ${{ steps.compressed-binary.outputs.name }}
file: ${{ steps.compressed-binary.outputs.path }}
body: Pre-built binaries of the Hive Gateway for the **@graphql-hive/gateway@${{ steps.ver-gateway.outputs.result }}** release.
overwrite: true
- if: github.event_name == 'pull_request'
name: Upload artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: ${{ steps.binary.outputs.name }}
path: ${{ steps.binary.outputs.path }}
- if: github.event_name == 'pull_request'
name: Comment on PR
uses: marocchino/sticky-pull-request-comment@v2
with:
# match pr comment like with changesets-snapshot-action from the guild's shared-config
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
header: snapshot-release-binary-${{ runner.os }}-${{ runner.arch }}
message: |
### 🚀 Snapshot Release (Binary for `${{ runner.os }}-${{ runner.arch }}`)
The latest changes of this PR are available for download (based on the declared `changesets`).
[![Download](https://custom-icon-badges.demolab.com/badge/-Download-blue?style=for-the-badge&logo=download&logoColor=white "Download")](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload.outputs.artifact-id }})