Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
run: >
markdownlint-cli2
"**/*.{md,markdown}"
"#**/CHANGELOG.md"

build:
needs: lint
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/_release_please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release Please

on:
workflow_call:
secrets:
GRAPH_FEDERATOR:
required: true

jobs:
release_please:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout source
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0

- name: Create GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1.11.0
with:
app-id: 1010045
private-key: ${{ secrets.GRAPH_FEDERATOR }}
repositories: graph-federation

- name: Release Please
id: release
uses: googleapis/release-please-action@v4.1.3
with:
token: ${{ steps.app-token.outputs.token }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
fork: false
39 changes: 23 additions & 16 deletions .github/workflows/_supergraph_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,52 @@ jobs:
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4.1.0

- name: Install release-please & simple-git
run: npm install release-please simple-git

- name: Generate Chart Version
id: version
uses: actions/github-script@v7.0.1
with:
result-encoding: string
script: |
const supergraph_tag = require('.github/workflows/supergraph_tag.js');
const token = "${{ github.token }}";
return await supergraph_tag({github, context, token})

- name: Setup Helm
if: steps.version.outputs.result != ''
uses: azure/setup-helm@v4.2.0

- name: Download Schema Artifact
if: steps.version.outputs.result != ''
uses: actions/download-artifact@v4.1.8
with:
name: supergraph.graphql
path: charts/supergraph

- name: Generate Chart Version
id: version
run: |
if LATEST_TAG=$(git describe --tags --abbrev=0); then
COMMITS_SINCE=$(git rev-list $LATEST_TAG..HEAD --count)
else
LATEST_TAG="0.0.0"
COMMITS_SINCE=$(git rev-list HEAD --count)
fi
VERSION=$([ "$COMMITS_SINCE" == 0 ] && echo "$LATEST_TAG" || echo "$LATEST_TAG+$COMMITS_SINCE" )
echo "Using Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Package Chart
run: helm package charts/supergraph --version "${{ steps.version.outputs.version }}"
if: steps.version.outputs.result != ''
run: helm package charts/supergraph --version ${{ steps.version.outputs.result }}

- name: Generate Image Name
if: steps.version.outputs.result != ''
run: |
IMAGE_REPOSITORY="oci://ghcr.io/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]')"
echo "Using Image Name: $IMAGE_REPOSITORY"
echo "IMAGE_REPOSITORY=$IMAGE_REPOSITORY" >> $GITHUB_ENV

- name: Log in to GitHub Docker Registry
if: github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/main') )
if: steps.version.outputs.result != '' && github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/main') )
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Chart
if: github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/main') )
if: steps.version.outputs.result != '' && github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/main') )
run: helm push $(ls supergraph-*.tgz) ${{ env.IMAGE_REPOSITORY }}
11 changes: 11 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/_lint_commits.yaml

release_please:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: ./.github/workflows/_release_please.yaml
permissions:
contents: write
pull-requests: write
id-token: write
secrets:
GRAPH_FEDERATOR: ${{ secrets.GRAPH_FEDERATOR }}

helm_lint:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
Expand All @@ -24,6 +34,7 @@ jobs:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs:
- release_please
- helm_lint
- supergraph_generate
uses: ./.github/workflows/_supergraph_publish.yaml
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/supergraph_tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const releasePlease = require('release-please');
const simpleGit = require('simple-git');

module.exports = async ({github, context, token}) => {
const ghRelease = await releasePlease.GitHub.create({
owner: context.repo.owner,
repo: context.repo.repo,
token: token,
});

const manifest = await releasePlease.Manifest.fromManifest(
ghRelease,
ghRelease.repository.defaultBranch,
'release-please-config.json',
'.release-please-manifest.json',
{}
);

const pullRequests = await manifest.buildPullRequests();
const pullRequest = pullRequests.find((pullRequest) => pullRequest.updates.some((update) => update.path === 'charts/supergraph/Chart.yaml'));
console.log(`Supergraph Pull Request: ${JSON.stringify(pullRequest)}`);

const git = simpleGit();
const lastTag = await git.raw('describe', '--tags', '--match', 'supergraph@v*', 'HEAD').catch((err) => undefined);
console.log(`Last Tag: ${JSON.stringify(lastTag)}`);
const commitsSince = lastTag ? await git.raw('rev-list', `${lastTag}..HEAD`, '--count') : await git.raw('rev-list', '--count', '--all');
console.log(`Commits Since: ${commitsSince}`);

let rcVersion = '';
if (pullRequest !== undefined) {

const releaseData = pullRequest.body.releaseData.find((release) => release.component === 'supergraph-schema');
rcVersion = commitsSince !== 0 ? `${releaseData.version.major}.${releaseData.version.minor}.${releaseData.version.patch}-rc${commitsSince}` : `${releaseData.version.major}.${releaseData.version.minor}.${releaseData.version.patch}`;
console.log(`Release Candidate Version: ${rcVersion}`);
} else if (lastTag !== undefined && commitsSince === 0) {
rcVersion = lastTag.split("@v").pop();
};

return rcVersion
}
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
53 changes: 53 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"bootstrap-sha": "ee1cb51e2177608be9e291f6bde17ca5d867016e",
"include-component-in-tag": true,
"include-v-in-tag": true,
"tag-separator": "@",
"separate-pull-requests": true,
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"packages": {
"charts/apps": {
"release-type": "helm",
"release-as": "0.2.2"
},
"charts/graph": {
"release-type": "helm",
"release-as": "0.11.1"
},
"charts/monitoring": {
"release-type": "helm",
"release-as": "0.2.0"
},
"charts/supergraph": {
"release-type": "helm",
"component": "supergraph"
},
"schema": {
"package-name": "supergraph-schema",
"release-type": "simple",
"component": "supergraph-schema"
},
"workflows/compose": {
"package-name": "compose",
"release-type": "simple",
"release-as": "0.1.0"
},
"workflows/update": {
"package-name": "update",
"release-type": "simple",
"release-as": "0.1.0"
}
},
"plugins": [
{
"type": "linked-versions",
"groupName": "supergraph",
"components": [
"supergraph",
"supergraph-schema"
]
}
]
}
Loading