From b2b015407b98db9b8deb4ef07c3b81a0ac078993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Wei=C3=9Fe?= Date: Tue, 11 Jun 2024 13:11:59 +0200 Subject: [PATCH] release: patch latest references in versioned docs --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++-- packages/scripts.nix | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 890f470d94..2e7678665e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -121,6 +121,7 @@ jobs: env: RELEASE_BRANCH: ${{ needs.process-inputs.outputs.RELEASE_BRANCH }} WORKING_BRANCH: ${{ needs.process-inputs.outputs.WORKING_BRANCH }} + MAJOR_MINOR: ${{ needs.process-inputs.outputs.MAJOR_MINOR }} steps: - name: Checkout working branch uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 @@ -150,16 +151,34 @@ jobs: git commit -am "docs: release ${{ needs.process-inputs.outputs.MAJOR_MINOR }}" # Clean up auxiliary files, so next steps run on a clean tree git clean -fx :/ + - name: Download image replacements file (from release branch) + uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e #v4.1.7 + with: + name: image-replacements.txt + path: ./image-replacements.txt + - name: Update release urls in docs with tags + working-directory: contrast-main + env: + MAJOR_MINOR: ${{ needs.process-inputs.outputs.MAJOR_MINOR }} + VERSION: ${{ inputs.version }} + REPLACEMENTS: ../image-replacements.txt + run: nix run ../contrast-working#scripts.update-release-urls + - name: Commit updated docs + working-directory: contrast-main + run: | + git add docs/versioned_docs/version-$MAJOR_MINOR + git commit -m "docs: update release download urls" - name: Download updated contrast releases file (from release branch) uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e #v4.1.7 with: name: contrast-releases.json - path: ./contrast-main/packages/contrast-releases.json + path: ./contrast-main/packages/ - name: Commit updated contrast-releases.json working-directory: contrast-main run: | git add ./packages/contrast-releases.json git commit -m "packages/contrast-releases: add ${{ needs.process-inputs.outputs.MAJOR_MINOR_PATCH }}" + git clean -fx :/ - name: Bump flake version to post release patch pre-version if: ${{ inputs.kind == 'minor' }} id: bump @@ -242,6 +261,11 @@ jobs: echo "ghcr.io/edgelesssys/contrast/initializer:latest=$initializerImgTagged" >> image-replacements.txt echo "ghcr.io/edgelesssys/contrast/service-mesh-proxy:latest=$serviceMeshImgTagged" >> image-replacements.txt echo "ghcr.io/edgelesssys/contrast/node-installer:latest=$nodeInstallerImgTagged" >> image-replacements.txt + - name: Upload image replacements file (for main branch PR) + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + name: image-replacements.txt + path: ./image-replacements.txt - name: Create portable coordinator resource definitions run: | mkdir -p workspace deployment @@ -275,7 +299,7 @@ jobs: name: contrast-releases.json path: ./packages/contrast-releases.json - name: Clean up git tree - run: git clean -fx :/ + run: git clean -f :/ - name: Create draft release uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 # v2.0.5 with: diff --git a/packages/scripts.nix b/packages/scripts.nix index b9540ad8b3..6a7b6ea9ae 100644 --- a/packages/scripts.nix +++ b/packages/scripts.nix @@ -193,4 +193,23 @@ ]; text = builtins.readFile ./update-contrast-releases.sh; }; + + update-release-urls = writeShellApplication { + name = "update-release-urls"; + text = '' + tag="[a-zA-Z0-9_.-]\{1,\}" + sha="@sha256:[a-fA-F0-9]\{64\}" + + while IFS= read -r line; do + image_source=$(echo "$line" | sed "s/:.*//" | sed "s/\./\\\./g") + image_target=$(echo "$line" | cut -d"=" -f2) + expr="$image_source\(:$tag\($sha\)\?\|$sha\)" + find "./docs/versioned_docs/version-$MAJOR_MINOR" -type f -exec sed -i "s#$expr#$image_target#g" {} \; + done <"$REPLACEMENTS" + + link_source="github\.com/edgelesssys/contrast/releases/\(latest/download\|download/$tag\)/" + link_target="github\.com/edgelesssys/contrast/releases/download/$VERSION/" + find "./docs/versioned_docs/version-$MAJOR_MINOR" -type f -exec sed -i "s#$link_source#$link_target#g" {} \; + ''; + }; }