diff --git a/.github/scripts/update-version.sh b/.github/scripts/update-version.sh new file mode 100755 index 00000000000..9a952ef39e0 --- /dev/null +++ b/.github/scripts/update-version.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +version=$1 + +sed -i "s/version=.*/version=$version/" gradle.properties diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eae2263fbbe..5a6c16f00f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,14 +37,56 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - if [[ $VERSION != *-BETA* ]] + if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then then - GA=" (GA)" + opt_ga=" (GA)" + else + opt_prerelease="--prerelease" fi # TODO (trask) remove --draft after the first successful release using this script gh release create --target main \ - --title "Version $VERSION$GA" \ + --title "Version $VERSION$opt_ga" \ --notes-file /tmp/release-notes.txt \ + $opt_prerelease \ --draft \ $VERSION \ applicationinsights-agent-$VERSION.jar + + bump-version: + runs-on: ubuntu-latest + needs: + - release + steps: + - uses: actions/checkout@v3 + + - name: Set environment variables + run: | + version=$(.github/scripts/get-version.sh) + if [[ $version =~ ^([0-9]+\.[0-9]+)\.([0-9]+)$ ]]; then + major_minor="${BASH_REMATCH[1]}" + patch="${BASH_REMATCH[2]}" + else + echo "unexpected version: $version" + exit 1 + fi + echo "NEXT_VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV + + - name: Update version + run: .github/scripts/update-version.sh $NEXT_VERSION + + - name: Create pull request against main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + message="Update version to $NEXT_VERSION" + body="Update version to \`$NEXT_VERSION\`." + branch="automation/update-version-to-${NEXT_VERSION}" + + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + git checkout -b "$branch" + git commit -a -m "$message" + git push --set-upstream origin HEAD:$branch + gh pr create --title "$message" \ + --body "$body"