Skip to content

Commit

Permalink
Update release action (#2678)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Nov 10, 2022
1 parent bfcf1d3 commit fcdf03d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/scripts/update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

version=$1

sed -i "s/version=.*/version=$version/" gradle.properties
48 changes: 45 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit fcdf03d

Please sign in to comment.