Skip to content

Commit

Permalink
fix: use previous minor release version for old dylib
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezs committed Jun 14, 2024
1 parent d42faa0 commit 11ad767
Showing 1 changed file with 74 additions and 1 deletion.
75 changes: 74 additions & 1 deletion .github/workflows/_25_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
FORCE_COLOR: 1
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
packages:
Expand All @@ -25,18 +26,90 @@ jobs:
steps:
- name: Checkout 🛒
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 0

- name: Download binaries from same run 📥
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-bin
path: ./target/release

- name: Download latest release binaries
- name: Is the branch a release/x.y branch?
run: |
BRANCH_NAME=${{ env.BRANCH_NAME }}
if [[ "${BRANCH_NAME}" =~ ^release/[0-9]+\.[0-9]+$ ]]; then
echo "Branch name ${BRANCH_NAME} does match the required format 'release/x.y'"
echo "IS_RELEASE_BRANCH=true" >> $GITHUB_ENV
else
echo "Branch name ${BRANCH_NAME} does NOT match the required format 'release/x.y."
echo "IS_RELEASE_BRANCH=false" >> $GITHUB_ENV
fi
- name: Extract version and compute previous version
id: extract_version
if: env.IS_RELEASE_BRANCH == 'true'
run: |
BRANCH_NAME=${{ env.BRANCH_NAME }}
VERSION=${BRANCH_NAME#release/}
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
# Compute the previous version
if [ $MINOR -eq 0 ]; then
PREV_MAJOR=$((MAJOR - 1))
if [ $PREV_MAJOR -ge 0 ]; then
PREV_VERSION="${PREV_MAJOR}"
else
echo "No previous version available"
exit 1
fi
else
PREV_MINOR=$((MINOR - 1))
PREV_VERSION="${MAJOR}.${PREV_MINOR}"
fi
echo "Previous version: $PREV_VERSION"
# Get the previous version from the environment variable
# PREV_VERSION=${{ env.PREV_VERSION }}
if [[ "$PREV_VERSION" == *.* ]]; then
# Find the highest tag matching the previous minor version prefix
HIGHEST_TAG=$(git tag -l "${PREV_VERSION}.*" | sort -V | tail -n 1)
else
# Find the highest tag for the previous major version
HIGHEST_TAG=$(git tag -l "${PREV_VERSION}.*.*" | sort -V | tail -n 1)
fi
if [ -z "$HIGHEST_TAG" ]; then
echo "No tags found for previous version $PREV_VERSION"
exit 1
fi
echo "HIGHEST_TAG=$HIGHEST_TAG"
PREVIOUS_RELEASE_COMMIT=$(git rev-list -n 1 $HIGHEST_TAG)
echo "PREVIOUS_RELEASE_COMMIT=$PREVIOUS_RELEASE_COMMIT"
echo "PREVIOUS_RELEASE_COMMIT=$PREVIOUS_RELEASE_COMMIT" >> $GITHUB_ENV
# If we're on a release branch we need to download the previous release binaries
- name: Download latest release binaries for release branch.
if: env.IS_RELEASE_BRANCH == 'true'
uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d
with:
workflow: release-berghain.yml
name: chainflip-backend-bin
commit: ${{ env.PREVIOUS_RELEASE_COMMIT }}
github_token: ${{ secrets.CF_BACKEND_GITHUB_TOKEN }}
path: latest-release

# If we're on main then the latest run of the release-sisyphos.yml workflow will have the latest release binaries
# Therefore we don't need to provide a commit.
- name: Download latest release binaries for main/PR branches.
if: env.IS_RELEASE_BRANCH == 'false'
uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d
with:
workflow: release-sisyphos.yml
name: chainflip-backend-bin
github_token: ${{ secrets.CF_BACKEND_GITHUB_TOKEN }}
path: latest-release

Expand Down

0 comments on commit 11ad767

Please sign in to comment.