Skip to content
Open
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
167 changes: 167 additions & 0 deletions .github/workflows/vcpkg-release-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Vcpkg release bump

# Opens a version-bump pull request against microsoft/vcpkg for the
# `cpp-client-telemetry` port whenever a new SDK release is published.
#
# It runs ONLY when a new version is cut:
# * automatically on a published, non-draft, non-prerelease GitHub Release
# whose tag looks like a version (vMAJOR.MINOR.PATCH.BUILD), or
# * manually via workflow_dispatch for a specific tag (recovery / re-run).
# It never runs on ordinary pushes, and it opens no PR if the port already
# matches the release (no version change).
#
# One-time setup required in this repository:
# * Variable VCPKG_FORK_REPO -> the vcpkg fork to push branches to,
# e.g. "your-org/vcpkg".
# * Secret VCPKG_BUMP_TOKEN -> a PAT (classic: repo+workflow, or
# fine-grained: Contents+Pull requests RW on
# the fork) able to push to VCPKG_FORK_REPO and
# open pull requests on microsoft/vcpkg.

on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Release tag to bump the vcpkg port to (e.g. v3.10.161.1)"
required: true
type: string

permissions:
contents: read

concurrency:
group: vcpkg-release-bump-${{ github.event.release.tag_name || inputs.tag }}
cancel-in-progress: false

jobs:
bump:
name: Bump cpp-client-telemetry port
# Skip drafts and pre-releases; always allow manual dispatch.
if: >-
${{ github.event_name == 'workflow_dispatch' ||
(github.event.release.draft == false && github.event.release.prerelease == false) }}
runs-on: ubuntu-latest
env:
UPSTREAM_REPO: ${{ github.repository }} # microsoft/cpp_client_telemetry
VCPKG_UPSTREAM: microsoft/vcpkg
VCPKG_FORK_REPO: ${{ vars.VCPKG_FORK_REPO }}
PORT: cpp-client-telemetry
steps:
- name: Validate configuration
env:
VCPKG_BUMP_TOKEN: ${{ secrets.VCPKG_BUMP_TOKEN }}
run: |
set -euo pipefail
if [ -z "${VCPKG_FORK_REPO}" ]; then
echo "::error::Repository variable VCPKG_FORK_REPO is not set (e.g. 'your-org/vcpkg')."
exit 1
fi
if [ -z "${VCPKG_BUMP_TOKEN}" ]; then
echo "::error::Secret VCPKG_BUMP_TOKEN is not set. Provide a token that can push to ${VCPKG_FORK_REPO} and open PRs on ${VCPKG_UPSTREAM}."
exit 1
fi

- name: Resolve tag and version
id: ver
run: |
set -euo pipefail
TAG="${{ github.event.release.tag_name }}"
if [ -z "${TAG}" ]; then TAG="${{ inputs.tag }}"; fi
if [ -z "${TAG}" ]; then echo "::error::No release tag could be resolved."; exit 1; fi
# Only act on version tags: vMAJOR.MINOR.PATCH.BUILD
if ! printf '%s' "${TAG}" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Tag '${TAG}' is not a version tag (expected vX.Y.Z.W); skipping."
exit 1
fi
VERSION="${TAG#v}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "branch=port/${PORT}-${VERSION}" >> "$GITHUB_OUTPUT"
echo "Bumping ${PORT} -> tag=${TAG} version=${VERSION}"

- name: Compute source archive SHA512
id: sha
run: |
set -euo pipefail
URL="https://github.com/${UPSTREAM_REPO}/archive/${{ steps.ver.outputs.tag }}.tar.gz"
echo "Downloading ${URL}"
curl -fsSL --retry 3 "${URL}" -o source.tar.gz
SHA512="$(sha512sum source.tar.gz | cut -d' ' -f1)"
echo "sha512=${SHA512}" >> "$GITHUB_OUTPUT"
echo "SHA512=${SHA512}"

- name: Clone vcpkg fork and branch off upstream master
env:
VCPKG_BUMP_TOKEN: ${{ secrets.VCPKG_BUMP_TOKEN }}
run: |
set -euo pipefail
git clone --depth 1 "https://x-access-token:${VCPKG_BUMP_TOKEN}@github.com/${VCPKG_FORK_REPO}.git" vcpkg
cd vcpkg
git remote add upstream "https://github.com/${VCPKG_UPSTREAM}.git"
git fetch --depth 1 upstream master
git checkout -B "${{ steps.ver.outputs.branch }}" upstream/master
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Bootstrap vcpkg
run: cd vcpkg && ./bootstrap-vcpkg.sh -disableMetrics

- name: Update port REF, SHA512 and version
run: |
set -euo pipefail
cd vcpkg
PORTFILE="ports/${PORT}/portfile.cmake"
MANIFEST="ports/${PORT}/vcpkg.json"
if [ ! -f "${PORTFILE}" ] || [ ! -f "${MANIFEST}" ]; then
echo "::error::${PORT} port not found in ${VCPKG_UPSTREAM}. The port must already be in the registry before it can be bumped."
exit 1
fi
sed -i -E "s|^([[:space:]]*REF[[:space:]]+).*$|\1${{ steps.ver.outputs.tag }}|" "${PORTFILE}"
sed -i -E "s|^([[:space:]]*SHA512[[:space:]]+).*$|\1${{ steps.sha.outputs.sha512 }}|" "${PORTFILE}"
jq --arg v "${{ steps.ver.outputs.version }}" '.version = $v | del(."port-version")' "${MANIFEST}" > "${MANIFEST}.tmp"
mv "${MANIFEST}.tmp" "${MANIFEST}"
./vcpkg format-manifest "${MANIFEST}"

- name: Detect change
id: diff
run: |
set -euo pipefail
cd vcpkg
if git diff --quiet -- "ports/${PORT}"; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No change: ${PORT} is already at ${{ steps.ver.outputs.version }} with this REF/SHA512. Nothing to do."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Commit, update version DB, push and open PR
if: ${{ steps.diff.outputs.changed == 'true' }}
env:
GH_TOKEN: ${{ secrets.VCPKG_BUMP_TOKEN }}
run: |
set -euo pipefail
cd vcpkg
BR="${{ steps.ver.outputs.branch }}"
git add "ports/${PORT}"
git commit -m "[${PORT}] Update to ${{ steps.ver.outputs.version }}"
./vcpkg x-add-version "${PORT}" --overwrite-version
git add versions
git commit -m "[${PORT}] Update version database"
# Ensure a remote-tracking ref exists so --force-with-lease has a lease
# to compare against on reruns: the bump branch may already exist on the
# fork but be absent from this fresh clone. Ignore failure on the first
# run, when the branch does not exist remotely yet.
git fetch origin "+refs/heads/${BR}:refs/remotes/origin/${BR}" || true
git push --force-with-lease origin "${BR}"
if [ -n "$(gh pr list --repo "${VCPKG_UPSTREAM}" --head "$(printf '%s' "${VCPKG_FORK_REPO}" | cut -d/ -f1):${BR}" --state open --json number --jq '.[0].number' 2>/dev/null)" ]; then
echo "An open PR already exists for ${BR}; the force-pushed branch refreshes it."
else
gh pr create \
--repo "${VCPKG_UPSTREAM}" \
--base master \
--head "$(printf '%s' "${VCPKG_FORK_REPO}" | cut -d/ -f1):${BR}" \
--title "[${PORT}] Update to ${{ steps.ver.outputs.version }}" \
--body "Automated port bump to [\`${UPSTREAM_REPO}@${{ steps.ver.outputs.tag }}\`](https://github.com/${UPSTREAM_REPO}/releases/tag/${{ steps.ver.outputs.tag }}). Generated by the \`vcpkg-release-bump\` workflow."
fi
4 changes: 2 additions & 2 deletions tools/ports/cpp-client-telemetry/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO microsoft/cpp_client_telemetry
REF 4485b82005abf1d24336ace99b11df88dd578eb0
SHA512 1f3ee1c26f1ae9e7323262c9b4c8796efba2c6addcde432d6c6c77b8c1c2f254cb8ff334b1dd0a72dc8ecfbfbae04ab374ec5ac7e5d286d6042953d53e50fd5b
REF v3.10.161.1
SHA512 4664b34ddce601d6a95669df4a59d11a6cc67de1f23de132192f791a275edc6a10b8498d340e6cf7d120d9e7a22c494d7517b24fc0954bf9e236e84a8800589a
HEAD_REF main
)

Expand Down
Loading