Found the problem with the last version and going negative. #265
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: yaml -*- | |
name: Tag new version | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
bump-and-tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Parse commit message for bump type | |
run: | | |
if ${{ contains(github.event.head_commit.message, '[bump patch]') || contains(github.event.head_commit.message, '[ci build]') }}; then | |
echo "bump=patch" >> $GITHUB_ENV | |
elif ${{ contains(github.event.head_commit.message, '[bump minor]') }}; then | |
echo "bump=minor" >> $GITHUB_ENV | |
elif ${{ contains(github.event.head_commit.message, '[bump major]') }}; then | |
echo "bump=major" >> $GITHUB_ENV | |
fi | |
- name: Checkout eman2 | |
if: ${{ env.bump }} | |
uses: actions/checkout@v2 | |
- name: Set up Git user | |
if: ${{ env.bump }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "eman-bot" | |
- name: Bump and tag new version | |
if: ${{ env.bump }} | |
run: | | |
git fetch --tags | |
version=$(git tag -l 'v*' --sort=-v:refname | head -n 1) | |
if [[ "$version" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
major="${BASH_REMATCH[1]}" | |
minor="${BASH_REMATCH[2]}" | |
patch="${BASH_REMATCH[3]}" | |
fi | |
case "${{ env.bump }}" in | |
major) | |
major=$((major + 1)) | |
minor=0 | |
patch=0 | |
;; | |
minor) | |
minor=$((minor + 1)) | |
patch=0 | |
;; | |
patch) | |
patch=$((patch + 1)) | |
;; | |
*) | |
echo "Unknown bump type: ${{ env.bump }}" | |
exit 1 | |
;; | |
esac | |
new_version="${major}.${minor}.${patch}" | |
echo "new_version=${new_version}" >> $GITHUB_ENV | |
echo "Current version: ${version}" | |
echo "Requested bump : ${{ env.bump }}" | |
echo "New version : ${new_version}" | |
sed -i "s/VERSION\s*[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/VERSION ${new_version}/" CMakeLists.txt | |
git add CMakeLists.txt | |
git commit -m v${new_version} | |
git tag -f v${new_version} | |
git push origin ${{ github.ref }} v${new_version} | |
- name: Checkout eman-feedstock | |
if: ${{ env.bump }} | |
uses: actions/checkout@v2 | |
with: | |
repository: cryoem/eman-feedstock | |
token: ${{ secrets.EMAN_DEV_TOKEN }} | |
- name: Update version in eman-feedstock | |
if: ${{ env.bump }} | |
run: | | |
sed -i 's/set\s*version\s*=\s*"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"/set version = "${{ env.new_version }}"/' recipe/meta.yaml | |
sed -i 's/set\s*build\s*=\s*[0-9][0-9]*/set build = 0/' recipe/meta.yaml | |
git add recipe/meta.yaml | |
git commit -m v${{ env.new_version }} | |
git push origin master |