From e44b3cad60ea7389fa26c2b1f12f2a33e696962c Mon Sep 17 00:00:00 2001 From: jerensl <54782057+jerensl@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:27:01 +0800 Subject: [PATCH] ci(cloude-release): add repository workflow for cloud release Signed-off-by: jerensl <54782057+jerensl@users.noreply.github.com> --- .github/workflows/release-docs.yml | 94 ++++++++++++++++++++++++++++++ build/meshery-cloud.version | 1 + meshery-cloud.version | 1 - 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-docs.yml create mode 100644 build/meshery-cloud.version delete mode 100644 meshery-cloud.version diff --git a/.github/workflows/release-docs.yml b/.github/workflows/release-docs.yml new file mode 100644 index 00000000..cc55dd61 --- /dev/null +++ b/.github/workflows/release-docs.yml @@ -0,0 +1,94 @@ +name: Publish Version Dispatcher +on: + repository_dispatch: + types: [cloud_version] + +jobs: + release_notes_docs_cloud_latest: + name: Release notes cloud with latest version + if: ${{ github.event.action == 'cloud_version' }} && ${{ github.event.client_payload.latest }} + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.RELEASEDRAFTER_PAT }} + repository: layer5io/docs + - name: Get Latest Meshery Cloud Release + id: meshery-cloud + env: + ACCESS_TOKEN: ${{ secrets.RELEASEDRAFTER_PAT }} + run: | + release_tag=$(curl -sL -H "Authorization: token $ACCESS_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/layer5io/meshery-cloud/releases/latest | jq -r ".tag_name") + echo "release_tag=$release_tag" >> $GITHUB_OUTPUT + current_tag=$(> $GITHUB_OUTPUT + - name: Get Release Info + if: steps.meshery-cloud.outputs.current_tag != steps.meshery-cloud.outputs.release_tag + env: + ACCESS_TOKEN: ${{ secrets.RELEASEDRAFTER_PAT }} + run: | + curl -sL -H "Authorization: token $ACCESS_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/layer5io/meshery-cloud/releases/latest > latest_release.json + + export RELEASE_TAG=$( cat latest_release.json | jq '.["tag_name"]' | tr -d '"') + export PRERELEASE=$( cat latest_release.json | jq '.["prerelease"]' | tr -d '"') + export RELEASE_BODY=$( cat latest_release.json | jq '.["body"]' | tr -d '"') + export DATE=$( cat latest_release.json | jq '.["published_at"]' | tr -d '"') + printf '%b\n' "---\ntitle: $RELEASE_TAG\ndate: $DATE\ntag: $RELEASE_TAG\nprerelease: $PRERELEASE\n---\n\n$RELEASE_BODY" > ./content/en/cloud/reference/releases/$RELEASE_TAG.md + - name: Update current release version + if: steps.meshery-cloud.outputs.current_tag != steps.meshery-cloud.outputs.release_tag + run: | + echo ${{ steps.meshery-cloud.outputs.release_tag }} > build/meshery-cloud.version + - uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.RELEASEDRAFTER_PAT }} + title: Release Notes Meshery Cloud version ${{ steps.meshery-cloud.outputs.release_tag }} + body: | + Updates [Meshery Cloud][1] to ${{ steps.meshery-cloud.outputs.release_tag }} + Auto-generated by [l5io][2] + [1]: https://meshery.layer5.io + [2]: https://github.com/l5io + push-to-fork: layer5io/docs + branch: meshery-cloud-release-${{ steps.meshery-cloud.outputs.release_tag }} + release_notes_docs_cloud_custom: + name: Release notes cloud with costum version + if: ${{ github.event.action == 'cloud_version' }} && ${{ !github.event.client_payload.latest}} + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.RELEASEDRAFTER_PAT }} + repository: layer5io/docs + - name: Get Latest Meshery Cloud Release + id: meshery-cloud + env: + ACCESS_TOKEN: ${{ secrets.RELEASEDRAFTER_PAT }} + run: | + release_tag=$(curl -sL -H "Authorization: token $ACCESS_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/layer5io/meshery-cloud/releases/tags/${{github.event.client_payload.version}} | jq -r ".tag_name") + echo "release_tag=$release_tag" >> $GITHUB_OUTPUT + current_tag=$(> $GITHUB_OUTPUT + - name: Get Release Info + if: steps.meshery-cloud.outputs.current_tag != steps.meshery-cloud.outputs.release_tag + env: + ACCESS_TOKEN: ${{ secrets.RELEASEDRAFTER_PAT }} + run: | + curl -sL -H "Authorization: token $ACCESS_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/layer5io/meshery-cloud/releases/tags/${{github.event.client_payload.version}} > latest_release.json + + export RELEASE_TAG=$( cat latest_release.json | jq '.["tag_name"]' | tr -d '"') + export PRERELEASE=$( cat latest_release.json | jq '.["prerelease"]' | tr -d '"') + export RELEASE_BODY=$( cat latest_release.json | jq '.["body"]' | tr -d '"') + export DATE=$( cat latest_release.json | jq '.["published_at"]' | tr -d '"') + printf '%b\n' "---\ntitle: $RELEASE_TAG\ndate: $DATE\ntag: $RELEASE_TAG\nprerelease: $PRERELEASE\n---\n\n$RELEASE_BODY" > ./content/en/cloud/reference/releases/$RELEASE_TAG.md + - uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.RELEASEDRAFTER_PAT }} + title: Release Notes Meshery Cloud version ${{ steps.meshery-cloud.outputs.release_tag }} + body: | + Updates [Meshery Cloud][1] to ${{ steps.meshery-cloud.outputs.release_tag }} + Auto-generated by [l5io][2] + [1]: https://meshery.layer5.io + [2]: https://github.com/l5io + push-to-fork: layer5io/docs + branch: meshery-cloud-release-${{ steps.meshery-cloud.outputs.release_tag }} \ No newline at end of file diff --git a/build/meshery-cloud.version b/build/meshery-cloud.version new file mode 100644 index 00000000..afaf360d --- /dev/null +++ b/build/meshery-cloud.version @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file diff --git a/meshery-cloud.version b/meshery-cloud.version deleted file mode 100644 index d2781879..00000000 --- a/meshery-cloud.version +++ /dev/null @@ -1 +0,0 @@ -v0.8.7 \ No newline at end of file