Skip to content

Bump version

Bump version #8

Workflow file for this run

name: Bump version
on:
workflow_dispatch:
inputs:
new_version:
type: string
description: New version number, like x.y.z
required: true
changelog:
type: string
description: Single line of details to prepend to `CHANGELOG`.
required: true
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Everything here was cribbed from or inspired by
# https://github.com/oflynned/android-version-bump/blob/b9f6de7f8bdf25de3f695843265debf7c3919272.
- name: Bump version
id: bump_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
old_version=$(sed -e 's/.*=//' version.properties)
echo "Bumping old version: $old_version to new version ${{ github.event.inputs.new_version }}."
echo "Changelog:"
echo "- ${{ github.event.inputs.changelog }}"
echo "# ${{ github.event.inputs.new_version }}" >> new_CHANGELOG.md
echo >> new_CHANGELOG.md
echo "- ${{ github.event.inputs.changelog }}" >> new_CHANGELOG.md
echo >> new_CHANGELOG.md
cat CHANGELOG.md >> new_CHANGELOG.md
mv new_CHANGELOG.md CHANGELOG.md
sed -i -e "s/$old_version/${{ github.event.inputs.new_version }}/" version.properties README.md
echo "version=${{ github.event.inputs.new_version }}" > version.properties
git diff
git config --global user.name "${GITHUB_USER:-Automated Version Bump}"
git config --global user.email "${GITHUB_EMAIL:-rust-android-gradle@users.noreply.github.com}"
git add --all
git commit -m "Prep for releasing version ${{ github.event.inputs.new_version }}."
git log -n 1
git tag "v${{ github.event.inputs.new_version }}"
remote="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push "${remote}" --follow-tags
git push "${remote}" --tags
echo "::set-output name=new_tag::v${{ github.event.inputs.new_version }}"
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump_version.outputs.new_tag }}
release_name: ${{ steps.bump_version.outputs.new_tag }}
body: "- ${{ github.event.inputs.changelog }}"
prerelease: false
draft: true