Respect CLI arguments and configuration when both provided #1408
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
env: | |
NODE_NO_WARNINGS: 1 | |
CI: true | |
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 | |
permissions: | |
contents: read | |
id-token: write | |
pull-requests: write | |
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 | |
permissions: | |
contents: read | |
id-token: write | |
pull-requests: write | |
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: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
runtime: [Node, Bun] | |
name: ${{ matrix.runtime }} Docker image | |
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${{ matrix.runtime == 'Bun' && '_bun' || '' }} | |
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-${{ matrix.runtime == 'Bun' && 'bun-' || '' }}docker-image | |
message: | | |
### 🚀 Snapshot Release (${{matrix.runtime}} 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 }}${{ matrix.runtime == 'Bun' && '-bun' || '' }} | |
``` | |
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 }}) |