forked from envoyproxy/go-control-plane
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lukasz Dziedziak <lukidzi@gmail.com>
- Loading branch information
1 parent
a0fe926
commit 5d309b2
Showing
2 changed files
with
100 additions
and
0 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,38 @@ | ||
#!/bin/bash | ||
|
||
current_tag=$(git tag --list --merged origin/release --sort=-creatordate | head -n 1) | ||
main_tag=$(git tag --list --merged main --sort=-creatordate | head -n 1) | ||
|
||
# Remove the prefix `v` and `-kong-*` suffix for comparison | ||
released_tag="${current_tag%-ld-*}" | ||
currentVersion="${released_tag#v}" | ||
|
||
# Main branch won't have -kong-* suffix | ||
newVersion="${main_tag#v}" | ||
|
||
# Convert versions to arrays | ||
IFS='.' read -r -a currentParts <<< "$currentVersion" | ||
IFS='.' read -r -a newParts <<< "$newVersion" | ||
|
||
echo "released_tag=$released_tag" >> $GITHUB_OUTPUT | ||
echo "main_tag=$main_tag" >> $GITHUB_OUTPUT | ||
|
||
echo "currentParts: ${currentParts[@]}" | ||
echo "newParts: ${newParts[@]}" | ||
|
||
# Compare each part | ||
for i in 0 1 2; do | ||
if [[ ${newParts[i]:-0} -gt ${currentParts[i]:-0} ]]; then | ||
echo "The new tag is higher." | ||
newVersionTag="${main_tag}-ld-1" | ||
echo "New version tag: $newVersionTag" | ||
echo "new_tag=$newVersionTag" >> $GITHUB_OUTPUT | ||
exit 0 | ||
elif [[ ${newParts[i]:-0} -lt ${currentParts[i]:-0} ]]; then | ||
echo "The current tag is higher. That shouldn't be that case, please fix tagging." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "The tags are equal." | ||
exit 0 |
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,62 @@ | ||
name: 'Sync with Upstream' | ||
|
||
on: | ||
schedule: | ||
- cron: '0 6 * * *' | ||
#scheduled at 06:00 everyday | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
actions: write | ||
contents: write | ||
|
||
jobs: | ||
sync-with-upstream-main: | ||
runs-on: ubuntu-latest | ||
name: Sync with upstream main | ||
steps: | ||
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.WORKFLOW_TOKEN }} | ||
- name: Sync upstream changes | ||
id: sync | ||
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1 | ||
with: | ||
target_sync_branch: main | ||
target_repo_token: ${{ secrets.WORKFLOW_TOKEN }} | ||
target_branch_push_args: "-f --tags" | ||
upstream_sync_branch: main | ||
upstream_sync_repo: envoyproxy/go-control-plane | ||
upstream_pull_args: "--tags" | ||
test_mode: false | ||
git_config_pull_rebase: true | ||
- run: | | ||
git config --global user.email "lukidzi@users.noreply.github.com" | ||
git config --global user.name "lukidzi" | ||
- name: New commits found | ||
if: steps.sync.outputs.has_new_commits == 'true' | ||
run: echo "New commits were found to sync." | ||
|
||
- name: No new commits | ||
if: steps.sync.outputs.has_new_commits == 'false' | ||
run: echo "There were no new commits." | ||
- name: Get new version tag | ||
id: new-version-tag | ||
if: steps.sync.outputs.has_new_commits == 'true' | ||
shell: bash | ||
run: ".github/scripts/get-version-tags.sh" | ||
- name: Print tags | ||
run: | | ||
echo ${{ steps.new-version-tag.outputs.released_tag }} | ||
echo ${{ steps.new-version-tag.outputs.main_tag }} | ||
echo ${{ steps.new-version-tag.outputs.new_tag }} | ||
- name: Release new version | ||
if: steps.new-version-tag.outputs.released_tag != steps.new-version-tag.outputs.main_tag | ||
run: | | ||
git remote -v | ||
git checkout release | ||
git pull | ||
git rebase --onto ${{ steps.new-version-tag.outputs.main_tag }} ${{ steps.new-version-tag.outputs.released_tag }} release | ||
git tag ${{ steps.new-version-tag.outputs.new_tag }} | ||
git push origin release --tags -f |