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
117 changes: 117 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Bump dataplane version

name: "version-bump.yml"

# Only run on manual triggers
on:
workflow_dispatch:
inputs:
new_version:
type: "string"
description: "The new version to set in Cargo.toml (e.g. '0.1.0'). Defaults to bumping the minor version if not provided."
required: false
default: ""

concurrency:
group: "${{ github.workflow }}:${{ github.ref }}"
cancel-in-progress: true

permissions:
contents: "write"
id-token: "write"
pull-requests: "write"

jobs:
bump_version:
name: "Bump version in Cargo.toml and create Pull Request"
runs-on: "lab"
steps:
- name: "Validate new version input"
if: ${{ inputs.new_version != '' }}
run: |
set -euo pipefail
new_version="${{ inputs.new_version }}"
semver_regex='^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'
if ! [[ "${new_version}" =~ ${semver_regex} ]]; then
echo "::error::'new_version' input ('${new_version}') is not a valid SemVer string (e.g. 1.2.3, 1.2.3-alpha.1+build.5)."
exit 1
fi

- name: "Install rust"
uses: "dtolnay/rust-toolchain@stable"

- name: "Install binstall"
uses: "cargo-bins/cargo-binstall@main"

# Use a GitHub App token so that the generated PR can trigger CI
- name: "Generate GitHub App token"
id: "app-token"
uses: "actions/create-github-app-token@v3"
with:
app-id: "${{ secrets.DP_APP_ID }}"
private-key: "${{ secrets.DP_PRIVATE_KEY }}"

Comment thread
qmonnet marked this conversation as resolved.
- name: "Install whyq"
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install --yes --no-install-recommends jq
cargo binstall --no-confirm whyq

- name: "Install just"
run: |
# This keeps our GH actions logs from getting messed up with color codes
echo 'deb [trusted=yes] https://apt.gabe565.com /' | sudo tee /etc/apt/sources.list.d/gabe565.list
sudo apt-get update
sudo apt-get install --yes --no-install-recommends just

- name: "Checkout"
uses: "actions/checkout@v6"
with:
persist-credentials: "false"
fetch-depth: "0"

- name: "Login to image cache"
run: |
echo "${REGISTRY_PASSWORD}" | docker login -u "${REGISTRY_USERNAME}" --password-stdin "${REGISTRY_URL}"

- name: "Install compile-env"
run: |
just --yes dpdp_sys_registry="${REGISTRY_URL}" refresh-compile-env
just --yes fake-nix

- name: "Bump version"
run: |
if [ -n "${{ inputs.new_version }}" ]; then
just bump_version "${{ inputs.new_version }}"
Comment thread
qmonnet marked this conversation as resolved.
else
just bump_minor_version --input=toml
fi
new_version="$(yq -r --input=toml '.workspace.package.version' Cargo.toml)"
echo "new_version=${new_version}" >> "${GITHUB_ENV}"

- name: "Commit changes"
run: |
if git diff --quiet; then
echo "No changes to commit"
exit 0
fi
git config user.name 'github-actions[bot]'
git config user.email '<41898282+github-actions[bot]@users.noreply.github.com>'
git commit -sam "bump: Bump dataplane version"

- name: "Create Pull Request"
uses: "peter-evans/create-pull-request@v8"
with:
token: "${{ steps.app-token.outputs.token }}"
branch: "bump/bump_dataplane_version"
Comment thread
qmonnet marked this conversation as resolved.
title: "Bump dataplane version"
body: |
Bump dataplane version to ${{ env.new_version }}.

Triggered by @${{ github.actor }}.

Do not forget to tag after merging!
labels: |
automated
sign-commits: "true"
13 changes: 9 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,17 @@ depgraph:

# Bump the minor version in Cargo.toml and reset patch version to 0
[script]
bump_minor_version:
CURRENT_VERSION=$(yq '.workspace.package.version' Cargo.toml)
bump_minor_version yq_flags="":
CURRENT_VERSION=$(yq -r {{ yq_flags }} '.workspace.package.version' Cargo.toml)
echo "Current version: ${CURRENT_VERSION}"
Comment thread
qmonnet marked this conversation as resolved.
MAJOR_VNUM=$(echo ${CURRENT_VERSION} | cut -d. -f1)
MINOR_VNUM=$(echo ${CURRENT_VERSION} | cut -d. -f2)
NEW_VERSION="${MAJOR_VNUM}.$((MINOR_VNUM + 1)).0"
echo "New version: ${NEW_VERSION}"
sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" Cargo.toml
just bump_version "${NEW_VERSION}"

# Bump the version in Cargo.toml to the specified version (for example, "1.2.3")
[script]
bump_version version:
echo "New version: {{ version }}"
sed -i "s/^version = \".*\"/version = \"{{ version }}\"/" Cargo.toml
Comment thread
qmonnet marked this conversation as resolved.
just cargo update -w
Loading