Check Versions #16333
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
name: Check Versions | |
on: | |
workflow_dispatch: | |
schedule: | |
# Run at minute 0 every 6 hours | |
- cron: '0 */6 * * *' | |
env: | |
LATEST_CHANNEL_DIR: ./channel-fuel-latest.toml.d/ | |
jobs: | |
# compare-versions: This job runs the compare-version script which collects | |
# latest versions released after the versions found in channel-fuel-latest.toml, | |
# filters out incompatible versions and uses the leftover as inputs to | |
# test-toolchain-compatibility job to run integration tests. | |
compare-versions: | |
name: Check versions | |
runs-on: ubuntu-latest | |
outputs: | |
should-run: ${{ steps.set-version-matrix.outputs.should-run }} | |
version-matrix: ${{ steps.set-version-matrix.outputs.version-matrix }} | |
steps: | |
- name: checkout master | |
uses: actions/checkout@v3 | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Checkout fuelup gh-pages | |
uses: actions/checkout@v3 | |
with: | |
repository: fuellabs/fuelup | |
path: gh-pages | |
ref: gh-pages | |
- uses: Swatinem/rust-cache@v1 | |
- name: Install compare-versions script | |
run: cargo install --debug --path ./ci/compare-versions | |
- name: Compare versions and set variables for tests if needed | |
id: set-version-matrix | |
run: | | |
compare-versions compatibility >> out | |
VERSIONS='' | |
# If file is empty, we have no new versions and we are done. | |
if [ -s out ]; then | |
# Read the output of compare-versions line-by-line | |
# for the versions newer than what is published within | |
# channel-fuel-latest.toml | |
while read line | |
do | |
if [ -d gh-pages/incompatible-versions ] && [ -e gh-pages/incompatible-versions/$line ]; then | |
# If an incompatible set is already published onto gh-pages, we do not add it to the matrix input for testing. | |
echo "incompatible versions: $line" | |
else | |
echo "::set-output name=should-run::true" | |
if [ -n "$VERSIONS" ]; then | |
VERSIONS+=',' | |
fi | |
# Next 4 lines is simply splitting the lines received from compare-versions into a JSON object. | |
# example line: | |
# [email protected] | |
# result: | |
# {"forc-version":"0.17.0","fuel-core-version":"0.9.4"} | |
# | |
# We append this string to VERSIONS. | |
FORC_VERSION="$(echo $line | cut -d '@' -f1 | cut -d '-' -f2-)" | |
FUEL_CORE_VERSION="$(echo $line | cut -d '@' -f2- | cut -d '-' -f3-)" | |
JSON_FMT='{"forc-version":"%s","fuel-core-version":"%s"}' | |
VERSIONS+=$(printf "$JSON_FMT" "$FORC_VERSION" "$FUEL_CORE_VERSION") | |
fi | |
done < "./out" | |
echo "Testing with versions: $VERSIONS" | |
echo "::set-output name=version-matrix::{\"job\":[$VERSIONS]}" | |
else | |
echo -e "\nNo new and untested versions; exiting" | |
fi | |
# test-compatibility: This job invokes test-toolchain-compatibility with | |
# version-matrix, a JSON string input, to trigger jobs to test compatibility | |
# between forc and fuel-core. | |
# | |
# This is only run if should-run is set to true. | |
test-compatibility: | |
name: Test compatibility | |
needs: compare-versions | |
if: ${{ needs.compare-versions.outputs.should-run == 'true' }} | |
uses: ./.github/workflows/test-toolchain-compatibility.yml | |
with: | |
version-matrix: ${{ needs.compare-versions.outputs.version-matrix }} | |
check-other-components-latest: | |
name: Check other components for their latest versions | |
needs: compare-versions | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install compare-versions script | |
run: cargo install --debug --path ./ci/compare-versions | |
- name: Install build-channel script | |
run: cargo install --debug --path ./ci/build-channel | |
- name: Check for latest versions of other components and execute build-channel | |
id: compare-rest | |
run: | | |
CHANNEL_TOML="channel-fuel-latest.toml" | |
compare-versions rest | |
if [[ -f "${CHANNEL_TOML}" ]]; then | |
echo "republish=true" >> $GITHUB_OUTPUT | |
mkdir -p ${{ env.LATEST_CHANNEL_DIR }} | |
cp $CHANNEL_TOML ${{ env.LATEST_CHANNEL_DIR }} | |
mkdir archive | |
PUBLISHED_DATE=$(date +'%Y-%m-%d') | |
cp $CHANNEL_TOML archive/channel-fuel-latest-${PUBLISHED_DATE}.toml | |
fi | |
- name: Deploy latest channel | |
if: ${{ steps.compare-rest.outputs.republish == 'true' }} | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ${{ env.LATEST_CHANNEL_DIR }} | |
keep_files: true | |
destination_dir: ./ | |
user_name: 'github-actions[bot]' | |
user_email: 'github-actions[bot]@users.noreply.github.com' | |
- name: Deploy latest channel (archive) | |
if: ${{ steps.compare-rest.outputs.republish == 'true' }} | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./archive | |
keep_files: true | |
destination_dir: ./channels/latest | |
user_name: 'github-actions[bot]' | |
user_email: 'github-actions[bot]@users.noreply.github.com' |