Skip to content

Commit

Permalink
ci: move build old and new binaries steps to separate jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed May 15, 2024
1 parent b138338 commit 6372129
Showing 1 changed file with 73 additions and 22 deletions.
95 changes: 73 additions & 22 deletions .github/workflows/software-upgrade-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,43 @@ jobs:
curl -L $SNAPSHOT_DOWNLOAD_URL -o $SNAPSHOT_FILE_PATH
if: steps.cache-snapshot.outputs.cache-hit != 'true'

pre-software-upgrade:
retrieve-old-binary:
runs-on: ubuntu-latest

needs: retrieve-latest-tag

outputs:
NEW_UPGRADE_ASSURE_BINARY_PATH: ${{ steps.build-new-binaries.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH }}
SNAPSHOT_DOWNLOAD_URL: ${{ steps.retrieve-info-json.outputs.SNAPSHOT_DOWNLOAD_URL }}
OLD_BINARY_PATH: ${{ steps.retrieve-latest-binary.outputs.OLD_BINARY_PATH }}

steps:
- name: Set old binary path
run: |
OLD_BINARY_PATH=/tmp/elysd-$LATEST_TAG
echo "OLD_BINARY_PATH=$OLD_BINARY_PATH" >> $GITHUB_ENV
echo "OLD_BINARY_PATH=$OLD_BINARY_PATH" >> $GITHUB_OUTPUT
- name: Cache old binary
uses: actions/cache@v4
id: cache-old-binary
with:
path: |
${{ env.OLD_BINARY_PATH }}
key: ${{ runner.os }}-snapshot-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}

- name: Retrieve latest binary
run: |
DOWNLOAD_URL=https://github.com/elys-network/elys/releases/download/$LATEST_TAG/elysd-$LATEST_TAG-linux-amd64
curl -L $DOWNLOAD_URL -o $OLD_BINARY_PATH && chmod +x $OLD_BINARY_PATH
# TODO: retrieve upgrade-assure and upload-snapshot binaries
if: steps.cache-old-binary.outputs.cache-hit != 'true'

build-new-binary:
runs-on: ubuntu-latest

outputs:
NEW_BINARY_PATH: ${{ steps.build-new-binaries.outputs.NEW_BINARY_PATH }}
NEW_UPGRADE_ASSURE_BINARY_PATH: ${{ steps.build-new-binaries.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH }}
UPLOAD_SNAPSHOT_BINARY_PATH: ${{ steps.build-new-binaries.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}

steps:
Expand All @@ -101,25 +129,6 @@ jobs:
with:
go-version: "1.21"

- name: Cache Directories
uses: actions/cache@v4
id: cache-elys-folders
with:
path: |
${{ env.HOME }}/.elys
${{ env.HOME }}/.elys2
key: ${{ runner.os }}-elys-folders-${{ env.LATEST_TAG }}

- name: Retrieve latest binary
run: |
DOWNLOAD_URL=https://github.com/elys-network/elys/releases/download/$LATEST_TAG/elysd-$LATEST_TAG-linux-amd64
OLD_BINARY_PATH=/tmp/elysd-$LATEST_TAG
curl -L $DOWNLOAD_URL -o $OLD_BINARY_PATH && chmod +x $OLD_BINARY_PATH
echo "OLD_BINARY_PATH=$OLD_BINARY_PATH" >> $GITHUB_ENV
# TODO: retrieve upgrade-assure and upload-snapshot binaries
if: steps.cache-elys-folders.outputs.cache-hit != 'true'

- name: Create git tag
run: git tag v999.999.999

Expand All @@ -143,6 +152,48 @@ jobs:
make build-upload-snapshot
UPLOAD_SNAPSHOT_BINARY_PATH=./build/upload-snapshot
echo "UPLOAD_SNAPSHOT_BINARY_PATH=$UPLOAD_SNAPSHOT_BINARY_PATH" >> $GITHUB_ENV
echo "UPLOAD_SNAPSHOT_BINARY_PATH=$UPLOAD_SNAPSHOT_BINARY_PATH" >> $GITHUB_OUTPUT
- name: Save new binary as artifact
uses: actions/upload-artifact@v3
with:
name: new-binary
path: |
${{ env.NEW_BINARY_PATH }}
${{ env.NEW_UPGRADE_ASSURE_BINARY_PATH}}
${{ env.UPLOAD_SNAPSHOT_BINARY_PATH }}
pre-software-upgrade:
runs-on: ubuntu-latest

needs: retrieve-latest-tag

outputs:
NEW_UPGRADE_ASSURE_BINARY_PATH: ${{ steps.build-new-binaries.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH }}
SNAPSHOT_DOWNLOAD_URL: ${{ steps.retrieve-info-json.outputs.SNAPSHOT_DOWNLOAD_URL }}
NEW_BINARY_PATH: ${{ steps.build-new-binaries.outputs.NEW_BINARY_PATH }}
UPLOAD_SNAPSHOT_BINARY_PATH: ${{ steps.build-new-binaries.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"

- name: Cache Directories
uses: actions/cache@v4
id: cache-elys-folders
with:
path: |
${{ env.HOME }}/.elys
${{ env.HOME }}/.elys2
key: ${{ runner.os }}-elys-folders-${{ env.LATEST_TAG }}

# TODO: to remove when upgrade-assure binary is available in previous release
- name: Copy upgrade assure folder
Expand Down

0 comments on commit 6372129

Please sign in to comment.