Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
ci: automatically bump the version number in rust-lang/gha-self-hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini authored and Mark-Simulacrum committed Feb 25, 2022
1 parent ed0b814 commit dedb530
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,9 @@ jobs:
asset_path: ${{ github.workspace }}/linux-arm64-trimmedpackages.json
asset_name: actions-runner-linux-arm64-${{ steps.releaseNote.outputs.version }}-trimmedpackages.json
asset_content_type: application/octet-stream

# Bump the version number in rust-lang/gha-self-hosted
- name: Bump the version number in rust-lang/gha-self-hosted
run: ./rust-bump-gha-self-hosted.sh
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
47 changes: 47 additions & 0 deletions rust-bump-gha-self-hosted.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
# This script updates the version number in rust-lang/gha-self-hosted after a
# release is made, removing the need for someone on the infrastructure team to
# bump the version number manually.
#
# It's executed by .github/workflows/release.yml

set -euo pipefail
IFS=$'\n\t'

repository_url="[email protected]:rust-lang/gha-self-hosted.git"
version_file="images/ubuntu/files/gha-runner-version"

git_name="rust-lang/gha-runner"
git_email="[email protected]"

# Load the deploy key on a temporary file.
key="$(mktemp)"
trap "rm ${key}" EXIT
echo "${DEPLOY_KEY}" > "${key}"

# Use the SSH key stored earlier for all git operations, and ignore ssh-agent.
export GIT_SSH_COMMAND="ssh -i ${key}"
unset SSH_AUTH_SOCK

# Clone the repository
clone="$(mktemp -d)"
trap "rm -rf ${clone}" EXIT
git clone "${repository_url}" "${clone}"

# Update the version file
version="$(cat releaseVersion)"
if [[ "$(cat "${clone}/${version_file}")" = "${version}" ]]; then
echo "nothing to update, exiting"
else
echo "${version}" > "${clone}/${version_file}"
(
cd "${clone}"
git add .
git \
-c commit.gpgsign=false \
-c "user.name=${git_name}" \
-c "user.email=${git_email}" \
commit -m "Bump the GitHub Actions runner to version ${version}"
git push
)
fi

0 comments on commit dedb530

Please sign in to comment.