From 6bb381bd0e8e36e494c6853c83a53407d691804d Mon Sep 17 00:00:00 2001 From: qui-pham Date: Fri, 5 Jan 2024 09:56:26 +0700 Subject: [PATCH 1/2] chore: change from automate to create PR --- .../create-PR-release-to-network.yml | 43 ++++++++++++++ .github/workflows/create-release-tag.yml | 58 +++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/create-PR-release-to-network.yml create mode 100644 .github/workflows/create-release-tag.yml diff --git a/.github/workflows/create-PR-release-to-network.yml b/.github/workflows/create-PR-release-to-network.yml new file mode 100644 index 00000000..03a5f50a --- /dev/null +++ b/.github/workflows/create-PR-release-to-network.yml @@ -0,0 +1,43 @@ +name: Create PR from release to network + +on: + pull_request: + branches: + - release/* + types: + - closed + +env: + HEAD_BRANCH: ${{ github.head_ref || github.ref_name }} + RELEASE_BRANCH: ${{ github.event.pull_request.base.ref}} + +jobs: + merge-release-to-network: + runs-on: ubuntu-latest + if: ${{ (github.event.pull_request.merged == true) && (contains(github.head_ref, 'deploy') || contains(github.ref_name, 'deploy')) }} + steps: + - name: Set Env + run: | + echo "PR_BRANCH=merge/${HEAD_BRANCH}" >> $GITHUB_ENV + echo "VERSION=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\///' | cut -d'-' -f1)" >> $GITHUB_ENV + echo "NETWORK=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\/v[0-9\.]*-\(.*\)/\1/')" >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ env.NETWORK }} + + - name: Reset promotion branch + run: | + git fetch origin ${RELEASE_BRANCH}:${RELEASE_BRANCH} + git reset --hard ${RELEASE_BRANCH} + + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 #v5.0.2 + with: + labels: automated PR + delete-branch: true + title: 'chore(`${{ env.NETWORK }}`): merge from `${{ env.HEAD_BRANCH}}`' + body: ${{ steps.template.outputs.result }} + branch: ${{env.PR_BRANCH}} diff --git a/.github/workflows/create-release-tag.yml b/.github/workflows/create-release-tag.yml new file mode 100644 index 00000000..ebe8e9cb --- /dev/null +++ b/.github/workflows/create-release-tag.yml @@ -0,0 +1,58 @@ +name: Create Release Tag + +on: + pull_request: + types: [closed] + branches: + - mainnet + - testnet + +env: + HEAD_BRANCH: ${{ github.head_ref || github.ref_name }} + +jobs: + create-release-tag: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + steps: + - name: Set Env + run: | + echo "VERSION=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\///' | cut -d'-' -f1)" >> $GITHUB_ENV + echo "NETWORK=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\/v[0-9\.]*-\(.*\)/\1/')" >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ env.NETWORK }} + + - name: Set Mainnet Tag + if: ${{ env.NETWORK == 'mainnet' }} + run: | + echo "TAG=${{ env.VERSION }}" >> $GITHUB_ENV + + - name: Set Testnet Tag + if: ${{ env.NETWORK == 'testnet' }} + run: | + echo "TAG=${{ env.VERSION }}-testnet" >> $GITHUB_ENV + + - name: Get Testnet Latest Tag + if: ${{ env.NETWORK == 'testnet' }} + run: | + echo "LATEST_TAG=$(git describe --tags --match "*testnet*" --abbrev=0)" >> $GITHUB_ENV + + - name: Get Mainnet Latest Tag + if: ${{ env.NETWORK == 'mainnet' }} + run: | + echo "LATEST_TAG=$(git describe --tags --match "*mainnet*" --abbrev=0)" >> $GITHUB_ENV + + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ env.TAG }} + run: | + gh release create "$tag" \ + --repo "$GITHUB_REPOSITORY" \ + --title "${{ env.NETWORK }} release ${{ env.VERSION }}" \ + --target "${{ env.NETWORK }}" \ + --notes-start-tag "${{ env.LATEST_TAG }}" \ + --generate-notes From 1f8beb76ff2e74829bd9b82b0020d8371163f936 Mon Sep 17 00:00:00 2001 From: qui-pham Date: Fri, 5 Jan 2024 09:56:42 +0700 Subject: [PATCH 2/2] chore: delete automerge --- .../workflows/merge-release-to-network.yml | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 .github/workflows/merge-release-to-network.yml diff --git a/.github/workflows/merge-release-to-network.yml b/.github/workflows/merge-release-to-network.yml deleted file mode 100644 index b37eaed2..00000000 --- a/.github/workflows/merge-release-to-network.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Merge release to network - -on: - pull_request: - branches: - - release/* - types: - - closed - -env: - HEAD_BRANCH: ${{ github.head_ref || github.ref_name }} - RELEASE_BRANCH: ${{ github.event.pull_request.base.ref}} -permissions: - contents: write - pull-requests: write - -jobs: - merge-release-to-network: - runs-on: ubuntu-latest - if: ${{ github.event.pull_request.merged == true && (contains(github.head_ref, 'deploy') || contains(github.ref_name, 'deploy')) }} - steps: - - name: Set Env - run: | - echo "PR_BRANCH=merge/${HEAD_BRANCH}" >> $GITHUB_ENV - echo "VERSION=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\///' | cut -d'-' -f1)" >> $GITHUB_ENV - echo "NETWORK=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\/v[0-9\.]*-\(.*\)/\1/')" >> $GITHUB_ENV - - - name: Set Mainnet Tag - if: ${{ env.NETWORK == 'mainnet' }} - run: | - echo "TAG=${{ env.VERSION }}" >> $GITHUB_ENV - - - name: Set Testnet Tag - if: ${{ env.NETWORK == 'testnet' }} - run: | - echo "TAG=${{ env.VERSION }}-testnet" >> $GITHUB_ENV - - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - ref: ${{ env.NETWORK }} - - - name: Reset promotion branch - run: | - git fetch origin ${HEAD_BRANCH}:${HEAD_BRANCH} - git reset --hard ${HEAD_BRANCH} - - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 #v5.0.2 - with: - labels: automated PR, automerge - delete-branch: true - title: 'chore(`${{ env.NETWORK }}`): merge from `${{ env.HEAD_BRANCH}}`' - body: ${{ steps.template.outputs.result }} - branch: ${{ env.PR_BRANCH }} - - - name: Auto Merge - id: automerge - uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - MERGE_METHOD: merge - MERGE_DELETE_BRANCH: true - PULL_REQUEST: ${{ steps.cpr.outputs.pull-request-number }} - - - name: Create release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ env.TAG }} - run: | - gh release create "$tag" \ - --repo="$GITHUB_REPOSITORY" \ - --title="${{ env.NETWORK }} - ${{ env.VERSION }}" \ - --notes-start-tag="v0.3.2-testnet" \ - --generate-notes -