From aa4c39c9c40952a959d258f434fce380bb084e61 Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Wed, 14 Feb 2024 11:26:24 +0100 Subject: [PATCH] chore: add an action to automate releases (#3035) Add a new GitHub action to automate the creation of release pull requests. --- .github/workflows/prepare-release.yml | 88 +++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/prepare-release.yml diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000000..9b4f594420 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,88 @@ +name: Prepare Release + +on: + workflow_dispatch: + inputs: + version: + description: New release version + required: true + type: choice + default: minor + options: + - major + - minor + - patch + +jobs: + create-release-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: "${{ secrets.RENKUBOT_GITHUB_TOKEN }}" + - name: Setup Git + run: | + git config --global --add user.name "Renku Bot" + git config --global --add user.email "renku@datascience.ch" + git config push.autoSetupRemote true + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: "20.11.0" + - name: Get old version + id: get_old_version + run: | + VERSION=$(npm version --json | grep "renku-ui" | awk -F: '{ print $2 }' | awk -F'"' '{ print $2 }') + echo "$VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + working-directory: ./client + - name: Bump client version + run: npm version ${{ github.event.inputs.version }} + working-directory: ./client + - name: Bump server version + run: npm version ${{ github.event.inputs.version }} + working-directory: ./server + - name: Get version + id: get_version + run: | + VERSION=$(npm version --json | grep "renku-ui" | awk -F: '{ print $2 }' | awk -F'"' '{ print $2 }') + echo "$VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + working-directory: ./client + - name: Bump version in Chart.yaml and values.yaml + run: | + sed -i -e"s/${{ steps.get_old_version.outputs.version }}/${{ steps.get_version.outputs.version }}/" Chart.yaml values.yaml + working-directory: ./helm-chart/renku-ui + - name: Create Branch + run: git switch -c "release-${{ steps.get_version.outputs.version }}" + # TODO: implement this step + # - name: Update changelog + # id: changelog + # run: | + # sed -i -E "s/^(.*.. _changelog:)/\1\n\n${{ github.event.inputs.version }}\n$DELIMITER\n\n/" CHANGELOG.rst + # head -n 10 CHANGELOG.rst + - name: Commit changes + run: | + git add client server helm-chart CHANGELOG.md + git commit -m "build: release ${{ steps.get_version.outputs.version }}" + git push + - name: Create Pull Request + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.RENKUBOT_GITHUB_TOKEN }} + script: | + const { repo, owner } = context.repo; + const result = await github.rest.pulls.create({ + title: 'release ${{ steps.get_version.outputs.version }}', + owner, + repo, + head: 'release-${{ steps.get_version.outputs.version }}', + base: 'main', + body: [ + 'Release ${{ steps.get_version.outputs.version }}', + '', + 'This PR is auto-generated by [actions/github-script](https://github.com/actions/github-script).', + '', + '/deploy ', + ].join('\n') + });