From 36aa81bac8e245f8a68cc65cc248b46f34542f18 Mon Sep 17 00:00:00 2001 From: Viktor Delev Date: Mon, 11 Nov 2024 17:46:37 +0100 Subject: [PATCH] fix lin error --- .github/workflows/release-post-merge.yml | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/release-post-merge.yml diff --git a/.github/workflows/release-post-merge.yml b/.github/workflows/release-post-merge.yml new file mode 100644 index 00000000..33718a07 --- /dev/null +++ b/.github/workflows/release-post-merge.yml @@ -0,0 +1,69 @@ +name: Post-Merge Release Actions + +on: + pull_request: + types: [closed] + branches: + - 'main' + +env: + GITHUB_USER: "datavisyn-bot" + GITHUB_TOKEN: ${{ secrets.DATAVISYN_BOT_REPO_TOKEN }} + +jobs: + post_release: + if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release') }} + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }} + + - name: Generate Release Notes + id: generate-release-notes + run: | + TAG_NAME="v$(echo "${{ github.event.pull_request.title }}" | awk '{print $2}')" + response=$(curl -s -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + https://api.github.com/repos/${{ github.repository }}/releases/generate-notes \ + -d "$(jq -n --arg tag_name "$TAG_NAME" \ + --arg target_commitish "main" \ + '{tag_name: $tag_name, target_commitish: $target_commitish}')") + echo "$response" | jq -r '.body' > release_notes.txt + + - name: Create GitHub Release + run: | + TAG_NAME="v$(echo "${{ github.event.pull_request.title }}" | awk '{print $2}')" + RELEASE_NOTES=$(cat release_notes.txt) + curl -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository.full_name }}/releases \ + -d '{ + "tag_name": "'"$TAG_NAME"'", + "target_commitish": "main", + "name": "'"$TAG_NAME"'", + "body": "'"$RELEASE_NOTES"'", + "draft": false, + "prerelease": false + }' + + - name: Merge Main into Develop + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "<>" + git checkout develop + git pull origin main + git push origin develop + + - name: Update Package Version for Next Development Cycle + run: | + CURRENT_VERSION=$(jq -r '.version' package.json) + NEW_VERSION=$(echo "$CURRENT_VERSION" | awk -F. -v OFS=. '{$NF += 1 ; print $0"-SNAPSHOT"}') + jq --arg new_version "$NEW_VERSION" '.version = $new_version' package.json > tmp.json && mv tmp.json package.json + + git add package.json + git commit -m "Bump to $NEW_VERSION" + git push origin develop