Skip to content

Merge pull request #19 from AllenInstitute/bugfix/s3-check-paths-in-sync #21

Merge pull request #19 from AllenInstitute/bugfix/s3-check-paths-in-sync

Merge pull request #19 from AllenInstitute/bugfix/s3-check-paths-in-sync #21

Workflow file for this run

name: Bump Version and Tag
on:
push:
branches: [ main ]
paths-ignore:
- '**/_version.py'
workflow_dispatch:
inputs:
bump_type:
description: 'Version bump type to use. If target_version is set, this will be ignored.'
type: choice
options: ['major', 'minor', 'patch', 'none']
required: false
default: 'none'
target_version:
description: |
Optional target version (e.g. 1.2.3) to bump to. If not set, bump type will be used.
(leave empty for default)
required: false
default: ''
dry_run:
description: 'Dry Run'
type: boolean
required: false
default: false
jobs:
get-version-info:
name: Get New Version Tag
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]'
outputs:
version: ${{ steps.set-target-version.outputs.version || steps.version-tag.outputs.version }}
version_tag: ${{ steps.set-target-version.outputs.version_tag || steps.version-tag.outputs.version_tag }}
version_type: ${{ steps.set-target-version.outputs.version_type || steps.version-tag.outputs.version_type }}
previous_version: ${{ steps.get-current-version.outputs.previous_version || steps.version-tag.outputs.previous_version }}
update_required: ${{ steps.set-update-required.outputs.update_required }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Bumped Version Tag
uses: ./.github/actions/bump-version-tag
id: version-tag
with:
bump_type: ${{ github.event.inputs.bump_type }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print Version Info
# We only want to print if we are not a workflow call or if the target version is 'N/A'
if: github.event_name != 'workflow_dispatch' || !inputs.target_version
run: |
echo "Version: ${{ steps.version-tag.outputs.version }}"
echo "Version Tag: ${{ steps.version-tag.outputs.version_tag }}"
echo "Version Type: ${{ steps.version-tag.outputs.version_type }}"
echo "Previous Version: ${{ steps.version-tag.outputs.previous_version }}"
- name: Set Target Version
id: set-target-version
# We only want to set the target version if we are a workflow call and the target version is set
if: github.event_name == 'workflow_dispatch' && inputs.target_version
run: |
echo "Setting target version to ${{ inputs.target_version }}"
echo "version=${{ inputs.target_version }}" >> $GITHUB_OUTPUT
echo "version_tag=v${{ inputs.target_version }}" >> $GITHUB_OUTPUT
- name: Get Current Version
id: get-current-version
# We only want to get current version if we are a workflow call and the target version is set
if: github.event_name == 'workflow_dispatch' && inputs.target_version
uses: ./.github/actions/source-code-version-get
with:
version_file: _version.py
- name: Set Update Required
id: set-update-required
run: |
if [ "${{ steps.set-target-version.outputs.version || steps.version-tag.outputs.version }}" != "${{ steps.version-tag.outputs.previous_version }}" ]; then
echo "Update required"
echo "update_required=true" >> $GITHUB_OUTPUT
else
echo "No update required"
echo "update_required=false" >> $GITHUB_OUTPUT
fi
update-version-and-tag:
name: Update Repo Tag and Version
runs-on: ubuntu-latest
needs: get-version-info
# We only want to run if:
# 1. We are not the GitHub bot
# 2. We are not a workflow call or we are not in dry run mode
# 3. The update is required (i.e. the version has changed)
if: |
github.actor != 'github-actions[bot]' &&
(github.event_name != 'workflow_dispatch' || !inputs.dry_run) &&
needs.get-version-info.outputs.update_required == 'true'
steps:
- uses: actions/checkout@v4
# This sets up the git user for the GitHub bot
- name: Configure Git User
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# This sets up ssh keys for the AllenInstitute GitHub
- name: Configure AllenInstitute Repo Authorization
uses: ./.github/actions/configure-org-repo-authorization
with:
token: ${{ secrets.AI_PACKAGES_TOKEN }}
ssh_private_key: ${{ secrets.AIBSGITHUB_PRIVATE_KEY }}
- name: Update Version
uses: ./.github/actions/source-code-version-update
with:
version: ${{ needs.get-version-info.outputs.version }}
version_tag: ${{ needs.get-version-info.outputs.version_tag }}
version_file: _version.py