Skip to content

Commit

Permalink
testing (bump)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpmcginty committed Mar 1, 2024
1 parent 20cf740 commit fc8334c
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 155 deletions.
86 changes: 0 additions & 86 deletions .github/actions/bump-version-tag/action.yml

This file was deleted.

134 changes: 134 additions & 0 deletions .github/actions/get-version-tag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Bump Version and Tag Reusable Workflow

on:
workflow_call:
inputs:
bump_type:
description: 'Version Bump Type'
type: choice
options: ['major', 'minor', 'patch', 'none']
required: false
default: 'none'
dry_run:
description: 'Dry Run'
type: boolean
required: false
default: false
secrets:
GITHUB_TOKEN:
description: 'Token for AllenInstitute GitHub'
required: true
GIT_SSH_PRIVATE_KEY:
description: 'SSH private key for AllenInstitute GitHub'
required: true
outputs:
major:
description: 'The major version number'
value: ${{ jobs.tag.outputs.major }}
minor:
description: 'The minor version number'
value: ${{ jobs.tag.outputs.minor }}
patch:
description: 'The patch version number'
value: ${{ jobs.tag.outputs.patch }}
increment:
description: 'The increment. This is the number of commits since the last tag.'
value: ${{ jobs.tag.outputs.increment }}
version:
description: 'The version number (e.g. 1.2.3)'
value: ${{ jobs.tag.outputs.version }}
version_tag:
description: 'The version tag (e.g. v1.2.3)'
value: ${{ jobs.tag.outputs.version_tag }}
version_type:
description: 'The version type (e.g. major, minor, patch, none)'
value: ${{ jobs.tag.outputs.version_type }}
previous_version:
description: 'The previous version number (e.g. 1.2.2)'
value: ${{ jobs.tag.outputs.previous_version }}

jobs:
tag:
name: Get New Tag
runs-on: ubuntu-latest
outputs:
major: ${{ steps.set-outputs.outputs.major }}
minor: ${{ steps.set-outputs.outputs.minor }}
patch: ${{ steps.set-outputs.outputs.patch }}
increment: ${{ steps.set-outputs.outputs.increment }}
version: ${{ steps.set-outputs.outputs.new_version }}
version_tag: ${{ steps.set-outputs.outputs.new_tag }}
version_type: ${{ steps.set-outputs.outputs.version_type }}
previous_version: ${{ steps.set-outputs.outputs.previous_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump patch version and tag
id: bump-version-tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: ${{ inputs.bump_type }}
MAJOR_STRING_TOKEN: '(MAJOR)'
MINOR_STRING_TOKEN: '(MINOR)'
PATCH_STRING_TOKEN: '(PATCH)'
NONE_STRING_TOKEN: '(NONE)'
WITH_V: "true"
RELEASE_BRANCHES: main
# We don't want to actually push the tag, just get the new tag here.
# We'll push the tag in the next step.
DRY_RUN: true
- name: Set Outputs
id: set-outputs
run: |
new_tag=${{ steps.bump-version-tag.outputs.new_tag }}
new_version=$(echo $new_tag | sed 's/^v//')
major=$(echo $new_version | cut -d. -f1)
minor=$(echo $new_version | cut -d. -f2)
patch=$(echo $new_version | cut -d. -f3)
increment=0
version_type=${{ steps.bump-version-tag.outputs.part }}
previous_version=$(git describe --tags --abbrev=0)
echo "::set-output name=major::${major}"
echo "::set-output name=minor::${minor}"
echo "::set-output name=patch::${patch}"
echo "::set-output name=increment::${increment}"
echo "::set-output name=version::${new_version}"
echo "::set-output name=version_tag::${new_tag}"
echo "::set-output name=version_type::${{ steps.bump-version-tag.outputs.part }}"
echo "::set-output name=previous_version::${previous_version}"
# Currently not using this Version bumping tool, but considering it for the future.
# The main limitation is being able to override the default bump type even
# if there are no commits.
- name: Bump Version Alternate
uses: PaulHatch/[email protected]
id: bump-version-tag-alt
with:
major_pattern: "/\((MAJOR|major|BREAKING|breaking)\)/"
minor_pattern: "/\((MINOR|minor|FEATURE|feature)\)/"
bump_each_commit: true
bump_each_commit_patch_pattern: "/\((PATCH|patch|BUG|bug|BUGFIX|bugfix|BUMP|bump)\)/"
- name: Set Outputs Alt
id: set-outputs-alt
run: |
echo 'changed: ${{ steps.bump-version-tag-alt.outputs.changed }}'
echo 'major: ${{ steps.bump-version-tag-alt.outputs.major }}'
echo 'minor: ${{ steps.bump-version-tag-alt.outputs.minor }}'
echo 'patch: ${{ steps.bump-version-tag-alt.outputs.patch }}'
echo 'increment: ${{ steps.bump-version-tag-alt.outputs.increment }}'
echo 'version: ${{ steps.bump-version-tag-alt.outputs.version }}'
echo 'version_tag: ${{ steps.bump-version-tag-alt.outputs.version_tag }}'
echo 'version_type: ${{ steps.bump-version-tag-alt.outputs.version_type }}'
echo 'previous_version: ${{ steps.bump-version-tag-alt.outputs.previous_version }}'
# echo "::set-output name=major::${{ steps.bump-version-tag-alt.outputs.major }}"
# echo "::set-output name=minor::${{ steps.bump-version-tag-alt.outputs.minor }}"
# echo "::set-output name=patch::${{ steps.bump-version-tag-alt.outputs.patch }}"
# echo "::set-output name=increment::${{ steps.bump-version-tag-alt.outputs.increment }}"
# echo "::set-output name=version::${{ steps.bump-version-tag-alt.outputs.version }}"
# echo "::set-output name=version_tag::${{ steps.bump-version-tag-alt.outputs.version_tag }}"
# echo "::set-output name=version_type::${{ steps.bump-version-tag-alt.outputs.version_type }}"
# echo "::set-output name=previous_version::${{ steps.bump-version-tag-alt.outputs.previous_version }}"
63 changes: 22 additions & 41 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,32 @@ on:
default: false

jobs:
tag:
name: Get New Tag
version-tag:
name: Get New Version Tag
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]'
outputs:
new_tag: ${{ steps.bump-version-tag.outputs.new_tag }}
tag: ${{ steps.bump-version-tag.outputs.tag }}
part: ${{ steps.bump-version-tag.outputs.part }}
major: ${{ steps.version-tag.outputs.major }}
minor: ${{ steps.version-tag.outputs.minor }}
patch: ${{ steps.version-tag.outputs.patch }}
increment: ${{ steps.version-tag.outputs.increment }}
version: ${{ steps.version-tag.outputs.version }}
version_tag: ${{ steps.version-tag.outputs.tag }}
version_type: ${{ steps.version-tag.outputs.type }}
previous_version: ${{ steps.version-tag.outputs.previous_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump patch version and tag
id: bump-version-tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: ${{ inputs.bump_type || 'none' }}
WITH_V: "true"
RELEASE_BRANCHES: main
DRY_RUN: true
- name: Bump Version Alternate
uses: PaulHatch/[email protected]
id: bump-version-tag-alt
- uses: ./.github/actions/get-version-tag
id: version-tag
with:
major_pattern: "/#(major|breaking)/"
minor_pattern: "/#(minor|feature)/"
bump_each_commit: true
bump_each_commit_patch_pattern: "/#(patch|bug|bugfix)/"
- name: Print Version Info
run: |
echo 'changed: ${{ steps.bump-version-tag-alt.outputs.changed }}'
echo 'increment: ${{ steps.bump-version-tag-alt.outputs.increment }}'
echo 'major: ${{ steps.bump-version-tag-alt.outputs.major }}'
echo 'minor: ${{ steps.bump-version-tag-alt.outputs.minor }}'
echo 'patch: ${{ steps.bump-version-tag-alt.outputs.patch }}'
echo 'version: ${{ steps.bump-version-tag-alt.outputs.version }}'
echo 'version_tag: ${{ steps.bump-version-tag-alt.outputs.version_tag }}'
bump_type: ${{ github.event.inputs.bump_type }}
update-version-and-tag:
name: Update Repo Tag and Version
runs-on: ubuntu-latest
needs: tag
if: github.actor != 'github-actions[bot]' && !inputs.dry_run && needs.tag.outputs.part != 'none'
needs: version-tag
if: |
github.actor != 'github-actions[bot]' &&
${{ !inputs.dry_run }} &&
needs.version-tag.outputs.version_type != 'none'
steps:
- uses: actions/checkout@v4
# This sets up the git user for the GitHub bot
Expand All @@ -85,12 +67,11 @@ jobs:
ssh_private_key: ${{ secrets.AIBSGITHUB_PRIVATE_KEY }}
- name: Update Version
env:
VERSION_TAG: ${{ needs.tag.outputs.tag }}
VERSION: ${{ needs.version-tag.outputs.version }}
VERSION_TAG: ${{ needs.version-tag.outputs.version_tag }}
run: |
echo "Updating version to ${{ env.VERSION_TAG }}"
new_version=$(echo $VERSION_TAG | sed 's/^v//')
echo "Release version: $new_version"
find src -name '_version.py' -exec sed -i "s/__version__ = .*/__version__ = \"$new_version\"/" {} \;
echo "Updating version to ${{ env.VERSION }} (${{ env.VERSION_TAG }})"
find src -name '_version.py' -exec sed -i "s/__version__ = .*/__version__ = \"${{ env.VERSION }}\"/" {} \;
git add src/**/_version.py
git commit -m "Bump version to ${{ env.VERSION_TAG }}"
git tag -a ${{ env.VERSION_TAG }} -m "Release ${{ env.VERSION_TAG }}"
Expand Down
50 changes: 22 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Release
name: Create Release

on:
# push:
# tags:
# - 'v*'
push:
tags:
- 'v*'

workflow_dispatch:
inputs:
Expand All @@ -18,27 +18,21 @@ on:
default: false

jobs:
package:
name: Package and Release
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Set up AllenInstitute Repo Authorization
uses: ./.github/actions/setup-ai-github-urls
with:
token: ${{ secrets.AI_PACKAGES_TOKEN }}
ssh_private_key: ${{ secrets.AIBSGITHUB_PRIVATE_KEY }}
- name: Run Packaging
run: |
make package
shell: bash
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Create Release with Changelog
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
name: Release ${{ github.event.inputs.tag || github.ref_name }}
body_path: changelog.md # Assumes you have a changelog.md file in your repository
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit fc8334c

Please sign in to comment.