forked from orange-cloudfoundry/k3s-boshrelease
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(github-action): create release-<x> branches
Based on k3s releases branches detection. It runs once a week on monday
- Loading branch information
Showing
2 changed files
with
72 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: create-release-branches | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
force_push: | ||
description: 'Force recreation of release branches from min version' | ||
required: true | ||
type: boolean | ||
default: false | ||
workflow_dispatch: | ||
inputs: | ||
force_push: | ||
description: 'Force recreation of release branches from min version' | ||
required: true | ||
type: boolean | ||
default: false | ||
schedule: | ||
- cron: "30 10 * * 1" # “At 10:30 on Monday.” https://crontab.guru/#30_10_*_*_1 | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# GH cli is already pre-install, see https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows | ||
|
||
- name: Install yq cli | ||
#See https://github.com/marketplace/actions/install-a-binary-from-github-releases | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: mikefarah/yq | ||
tag: v4.34.2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # reduce potential rate limiting | ||
|
||
- name: create-missing-branches | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
FORCE_PUSH: ${{ inputs.force_push}} | ||
run: | | ||
# configure git | ||
git config --global user.name "actions/k3s-boshrelease" | ||
git config --global user.email "<>" | ||
git config --global --add safe.directory /github/workspace | ||
./create-release-branches.bash | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
#!/bin/bash | ||
set -x | ||
#set -x | ||
set -e # exit on non-zero status | ||
|
||
for v in 1.25 1.26 1.27 1.28 1.29 1.30 1.31 ; do | ||
BRANCH_NAME="release-${v}" | ||
git branch -d $BRANCH_NAME | ||
git co -b $BRANCH_NAME | ||
PUSH_OPTIONS="" | ||
if [ $FORCE_PUSH = "true" ] ;then | ||
PUSH_OPTIONS="$PUSH_OPTIONS --force" | ||
fi | ||
current_version=$(yq -r '.directories[0].contents[] | select (.path=="k3s-io/k3s") | .githubRelease.tag ' ./vendir.yml) | ||
current_version=${current_version#v} | ||
MIN_VERSION=$(echo "$current_version"|cut -d'.' -f1-2) | ||
for ref in $(git ls-remote -h https://github.com/k3s-io/k3s "release-*" | sed 's/refs\/heads\///' | awk '{print $2}') ; do | ||
v=${ref#release-} | ||
BRANCH_NAME="${ref}" | ||
echo "Extracted values - v: $v - BRANCH_NAME: $BRANCH_NAME" | ||
if [ $(echo "$v <= $MIN_VERSION"|bc) -eq 1 ];then | ||
echo "Skipping version $v" | ||
continue | ||
else | ||
echo "Keeping $v as $v > $MIN_VERSION" | ||
fi | ||
continue | ||
git branch -d "$BRANCH_NAME" | ||
git co -b "$BRANCH_NAME" | ||
sed -i.orig "s/tag: v.*/tag: v${v}.0/g" vendir.yml | ||
! diff vendir.yml vendir.yml.orig | ||
rm vendir.yml.orig | ||
git add vendir.yml | ||
git commit -m "Initial branch creation for k8s version $v" | ||
git push --set-upstream origin $BRANCH_NAME --force | ||
! gh pr create --base master --repo orange-cloudfoundry/k3s-packages-boshrelease --fill --body "Track divergence of release branches with master" | ||
git push --set-upstream origin "$BRANCH_NAME" $PUSH_OPTIONS | ||
git co master | ||
done |