Skip to content

Commit

Permalink
release: patch latest references in versioned docs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidweisse committed Jun 12, 2024
1 parent c795e81 commit b2b0154
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions packages/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" {} \;
'';
};
}

0 comments on commit b2b0154

Please sign in to comment.