Skip to content

:octocat: Github action that compares versions based on the previous semantic version tag and the latest tag i.e (major, minor, patch, prerelease, build)

License

Notifications You must be signed in to change notification settings

tj-actions/semver-diff

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

CI Update release version. Public workflows that use this action.

semver-diff

Get the difference between two semantic versions using semver-tool

Example

Screen Shot 2021-05-24 at 7 13 32 AM

Usage

name: Get semver diff

on:
  release:
    types:
      - created
  push:
    tags:
      - v*

jobs:
  test:
    runs-on: ubuntu-latest
    name: semver-diff
    steps:
      - uses: actions/checkout@v3
      - name: Run semver-diff
        id: semver-diff
        uses: tj-actions/semver-diff@v3
      - name: Show release type
        run: |
          echo "Release type: ${{ steps.semver-diff.outputs.release_type }}"
        # Outputs: Release type: major || minor || patch || prerelease || build
name: Upload Python Package

on:
  release:
    types: [created]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Run semver-diff
        id: semver-diff
        uses: tj-actions/semver-diff@v3

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.6.x'

      - name: Install dependencies
        ...

      - name: Setup git
        run: |
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"

      - name: bumpversion
        run: |
          bump2version "${{ steps.semver-diff.outputs.release_type }}"
          git switch -c main 
       
      - name: Build and publish to PyPi
        ...
        
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          base: "main"
          ...

Inputs

INPUT TYPE REQUIRED DEFAULT DESCRIPTION
initial_release_type string true "patch" Initial release type returned when
there are no existing tags.

Outputs

OUTPUT TYPE DESCRIPTION
new_version string The current project version
old_version string The previous project version
release_type string The difference between two versions
by the release type (major, minor, patch, prerelease, build)

If you feel generous and want to show some extra appreciation:

Buy me a coffee

Credits

This package was created with Cookiecutter using cookiecutter-action

Report Bugs

Report bugs at https://github.com/tj-actions/semver-diff/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your workflow that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.