Skip to content

Commit

Permalink
Feature/new versioning (#41)
Browse files Browse the repository at this point in the history
* release 0.4.0

* fix versioning for release

* new versioning

* new version

---------

Co-authored-by: James Wood <James.F.Wood@jpl.nasa.gov>
  • Loading branch information
sliu008 and James Wood authored Jan 14, 2025
1 parent e087a15 commit 9bad88b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 100 deletions.
33 changes: 12 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
version: ${{ steps.versioning.outputs.new_version }}
changes: ${{ steps.check_changes.outputs.changes }}
pyproject_name: ${{ steps.versioning.outputs.pyproject_name }}
publish_version: ${{ steps.check_publish.outputs.publish_version }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -41,34 +40,30 @@ jobs:
# Combine version management logic into a single step
pyproject_name=$(poetry version | awk '{print $1}')
echo "pyproject_name=${pyproject_name}" >> $GITHUB_OUTPUT
echo "pyproject_name=${pyproject_name}" >> $GITHUB_ENV
current_version=$(poetry version -s)
echo "old_version=${current_version}" >> $GITHUB_ENV
base_version=$(echo "$current_version" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+')
# Version calculation based on branch
if [[ "${{ github.ref }}" =~ ^refs/heads/(issue|feature|dependabot)/ ]]; then
new_version="${current_version%%-*}+$(git rev-parse --short HEAD)"
new_version="${base_version%%-*}+$(git rev-parse --short HEAD)"
elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
if [[ ${current_version} =~ -alpha ]]; then
alpha_num=$((${current_version##*alpha.} + 1))
new_version="${current_version%%-*}-alpha.${alpha_num}"
else
new_version="${current_version}-alpha.1"
fi
new_version=$(poetry version prerelease -s)
elif [[ "${{ github.ref }}" =~ ^refs/heads/release/ ]]; then
if [[ ${current_version} =~ -rc ]]; then
rc_num=$((${current_version##*rc.} + 1))
new_version="${current_version%%-*}-rc.${rc_num}"
new_version=$(poetry version prerelease -s)
else
new_version="${current_version}-rc.1"
new_version="${GITHUB_REF#refs/heads/release/}rc1"
fi
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
new_version=${current_version%%-*}
new_version=${base_version}
fi
poetry version ${new_version}
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
echo "new_version=${new_version}" >> $GITHUB_ENV
poetry version ${new_version}
echo "old_version=${current_version}" >> $GITHUB_ENV
- name: Install Dependencies and Run Tests
run: |
Expand Down Expand Up @@ -168,12 +163,8 @@ jobs:
startsWith(github.ref, 'refs/heads/release/')
id: check_publish
run: |
FILE=$(ls dist/*.whl dist/*.tar.gz | head -n 1)
PUBLISHED_VERSION=$(basename "$FILE" | sed -E 's/^.*-([0-9]+\.[0-9]+\.[0-9a-zA-Z]+(\.[0-9]+)?)-.*$/\1/')
echo "publish_version=${PUBLISHED_VERSION}" >> $GITHUB_OUTPUT
PYPROJECT_NAME=$(poetry version | awk '{print $1}')
pip install tenacity logging
python3 ${GITHUB_WORKSPACE}/.github/workflows/wait-for-pypi.py $PYPROJECT_NAME==$PUBLISHED_VERSION
python3 ${GITHUB_WORKSPACE}/.github/workflows/wait-for-pypi.py ${{ env.pyproject_name }}==${{ env.new_version }}
publish:
name: Build & Publish Docker
Expand Down Expand Up @@ -247,7 +238,7 @@ jobs:
id: set-source
run: |
# Default build source for standard branches
echo "SOURCE=${{ needs.build.outputs.pyproject_name }}==${{ needs.build.outputs.publish_version }}" >> $GITHUB_ENV
echo "SOURCE=${{ needs.build.outputs.pyproject_name }}==${{ needs.build.outputs.version }}" >> $GITHUB_ENV
# Override source if deploying (find .whl file in dist/)
if [[ "${{ contains(github.event.head_commit.message, '/deploy sit') ||
Expand Down
43 changes: 10 additions & 33 deletions .github/workflows/release-created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,15 @@ jobs:
uses: abatilo/actions-poetry@v3
with:
poetry-version: 1.8.5

- name: Bump minor version
env:
COMMIT_VERSION: ${{ github.ref }}
run: |
# only update the develop branch if were making #.#.0 release
# Get the branch name from the GITHUB_REF environment variable
branch_name=${GITHUB_REF#refs/heads/}
# Extract the last number in the branch name using a regular expression
if [[ $branch_name =~ /([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
first_number=${BASH_REMATCH[1]}
middle_number=${BASH_REMATCH[2]}
last_number=${BASH_REMATCH[3]}
# Increment the middle number by 1
incremented_middle_number=$((middle_number + 1))
# Check if the last number is '0'
if [ "$last_number" == "0" ]; then
update_version=$first_number.$incremented_middle_number.$last_number-alpha.1
poetry version $update_version
echo "software_version=$update_version" >> $GITHUB_ENV
git config --global user.name 'podaac-forge-py bot'
git config --global user.email 'podaac-forge-py@noreply.github.com'
git commit -am "/version ${{ env.software_version }}"
git push
fi
fi
poetry version ${GITHUB_REF#refs/heads/release/}
poetry version preminor
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
- name: Commit Version Bump
run: |
git config --global user.name 'podaac-forge-py bot'
git config --global user.email 'podaac-forge-py@noreply.github.com'
git commit -am "/version ${{ env.software_version }}"
git push
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
### Deprecated
### Removed
### Fixed


## [0.4.0]

### Added
- Added in forge-py fargate terraform code
- Update and cleaned up github action
- Updated and cleaned up github action
### Deprecated
### Removed
### Fixed
Expand Down
Loading

0 comments on commit 9bad88b

Please sign in to comment.