Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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}"
92 changes: 92 additions & 0 deletions .github/workflows/schemastore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Update SchemaStore

on:
workflow_run:
workflows: [ 'Verify & Publish Docs' ]
types: [ completed ]
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:
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
Comment thread
arturcic marked this conversation as resolved.
Outdated
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

Check failure on line 28 in .github/workflows/schemastore.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make sure that no untrusted code is executed from a fork.

See more on https://sonarcloud.io/project/issues?id=GitTools_GitVersion&issues=AZ8m01NbQNFxXeYuB2Fi&open=AZ8m01NbQNFxXeYuB2Fi&pullRequest=5018
with:
ref: gh-pages
fetch-depth: 2

Comment thread
arturcic marked this conversation as resolved.
- name: Detect schema version
id: detect
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_VERSION: ${{ inputs.version }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
version="$INPUT_VERSION"
else
# docs.yml pushes a single commit to gh-pages per run, so the newly
# added schema folder (if any) is in the diff of the last commit.
version="$(git diff --name-only --diff-filter=A HEAD~1 HEAD -- '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."
Loading