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: 0 additions & 1 deletion .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ jobs:
brew bump-formula-pr gitversion \
--url "$url" \
--sha256 "$sha256" \
--fork-org gittools
--no-audit \
--no-browse \
--message "For additional details see https://github.com/GitTools/GitVersion/releases/tag/${version}"
95 changes: 95 additions & 0 deletions .github/workflows/schemastore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Update SchemaStore

on:
push:
branches:
- gh-pages
paths:
- schemas/**
workflow_dispatch:
Comment thread
arturcic marked this conversation as resolved.
inputs:
version:
description: 'GitVersion schema version to publish (e.g. 6.7)'
required: true

permissions:
contents: read

jobs:
update-schemastore:
name: Open PR to SchemaStore
runs-on: ubuntu-24.04
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: gh-pages
# Full history so the before/after SHAs from the push event are always
# available locally, regardless of how many commits the push contained.
fetch-depth: 0

- name: Detect schema version
id: detect
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_VERSION: ${{ inputs.version }}
BEFORE_SHA: ${{ github.event.before }}
AFTER_SHA: ${{ github.event.after }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
version="$INPUT_VERSION"
else
version="$(git diff --name-only --diff-filter=A "$BEFORE_SHA" "$AFTER_SHA" -- 'schemas/*/GitVersion.configuration.json' \
| sed -E 's#schemas/([^/]+)/.*#\1#' | sort -V | tail -1)"
fi
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Load GitHub release token
id: github-creds
if: steps.detect.outputs.version != ''
uses: gittools/cicd/github-creds@824c3d773fb5d1b00c26b474ae88b7ce9ae555ee # v5
with:
op_service_account_token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

- name: '[Update SchemaStore]'
if: steps.detect.outputs.version != ''
shell: bash
env:
GH_TOKEN: ${{ steps.github-creds.outputs.github_release_token }}
VERSION: ${{ steps.detect.outputs.version }}
run: |
set -euo pipefail

git config --global user.name "GitTools Bot"
git config --global user.email "gittoolsbot@outlook.com"

gh repo sync GitTools/schemastore --source SchemaStore/schemastore --branch master

workdir="$(mktemp -d)"
gh repo clone GitTools/schemastore "$workdir" -- --branch master
cd "$workdir"

branch="gitversion-schema-${VERSION}"
git checkout -b "$branch"

url="https://gitversion.net/schemas/${VERSION}/GitVersion.configuration.json"
catalog="src/api/json/catalog.json"
schemaRef="src/schemas/json/gitversion.json"

jq --arg url "$url" --arg version "$VERSION" \
'(.schemas[] | select(.name == "GitVersion")) |= (.url = $url | .versions[$version] = $url)' \
"$catalog" > "$catalog.tmp" && mv "$catalog.tmp" "$catalog"
Comment thread
arturcic marked this conversation as resolved.
jq --arg ref "$url" '."$ref" = $ref' "$schemaRef" > "$schemaRef.tmp" && mv "$schemaRef.tmp" "$schemaRef"

git commit -am "update gitversion schema to ${VERSION}" || { echo "Nothing to update, skipping PR."; exit 0; }
git push origin "$branch"

gh pr create --repo SchemaStore/schemastore --head "GitTools:${branch}" --base master \
--title "update gitversion schema to ${VERSION}" \
--body "Automated update of the GitVersion configuration schema for the ${VERSION} release."
9 changes: 9 additions & 0 deletions build/docs/Tasks/PublishDocs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ private static void PublishDocumentation(BuildContext context)
context.EnsureDirectoryExists(schemaTargetDir);
context.CopyDirectory(Paths.Schemas, schemaTargetDir);

// gh-pages needs its own copy of this workflow so that a push to gh-pages
// can trigger it directly (GitHub resolves push-triggered workflows using
// the file as it exists on the pushed branch, not on the default branch).
var workflowsTargetDir = publishFolder.Combine(".github").Combine("workflows");
context.EnsureDirectoryExists(workflowsTargetDir);
context.CopyFile(
Paths.Root.CombineWithFilePath(".github/workflows/schemastore.yml"),
workflowsTargetDir.CombineWithFilePath("schemastore.yml"));

if (!context.GitHasUncommitedChanges(publishFolder))
{
return;
Expand Down
Loading