Skip to content

update version

update version #33

Workflow file for this run

# Build Pipeline for hitide-backfill-lambdas
name: Build
# Controls when the workflow will run
on:
# Triggers the workflow on push events
push:
branches: [ develop, release/**, main, feature/**, issue/**, issues/**, dependabot/** ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# First job in the workflow installs and verifies the software
build:
name: Build, Test, Verify, Publish
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
#########################################################################
# Environment Setup
#########################################################################
# NOTE: This step is platform-specific
# Checks out this repository and sets up the build/test environment with
# gradle
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: 1.8.5
#########################################################################
# Versioning Summary
#########################################################################
- name: Version Management
id: versioning
run: |
current_version=$(poetry version -s)
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="${base_version%%-*}+$(git rev-parse --short HEAD)"
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV
new_version=$(poetry version prerelease -s)
elif [[ "${{ github.ref }}" =~ ^refs/heads/release/ ]]; then
echo "TARGET_ENV_UPPERCASE=UAT" >> $GITHUB_ENV
if [[ ${current_version} =~ rc ]]; then
new_version=$(poetry version prerelease -s)
else
new_version="${GITHUB_REF#refs/heads/release/}rc1"
fi
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "TARGET_ENV_UPPERCASE=OPS" >> $GITHUB_ENV
new_version=${base_version}
fi
echo "new_version=${new_version}" >> $GITHUB_ENV
- name: Override Environment for Deploy Command
if: contains(github.event.head_commit.message, '/deploy')
run: |
message="${{ github.event.head_commit.message }}"
override_env=$(echo "$message" | grep -oE '/deploy (sit|uat)' | awk '{print $2}')
if [[ -n "$override_env" ]]; then
override_env_upper=$(echo "$override_env" | tr '[:lower:]' '[:upper:]')
echo "TARGET_ENV_UPPERCASE=${override_env_upper}" >> $GITHUB_ENV
echo "TARGET_ENV_LOWERCASE=${override_env}" >> $GITHUB_ENV
echo "Overriding deployment target to: ${override_env_upper}"
fi
- name: Set Lowercase Environment
run: |
echo "TARGET_ENV_LOWERCASE=$(echo ${{ env.TARGET_ENV_UPPERCASE }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
# Update the version number in the application package itself
- name: Update version number in the application package
run: |
poetry version ${{ env.new_version }}
#########################################################################
# Install & Test & Snyk
#########################################################################
# NOTE: This step is platform-specific
# These are gradle-specific steps for installing the application
- name: Install Software
run: |
pip install pylint
pip install pytest
poetry build
poetry install
# This is where tests go
- name: Run Poetry Tests
run: |
poetry run pylint podaac
poetry run flake8 podaac
poetry run pytest --junitxml=build/reports/pytest.xml --cov=podaac/ --cov-report=html -m "not aws and not integration" tests/
- name: Run Snyk as a blocking step
uses: snyk/actions/python@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: test
args: >
--org=${{ secrets.SNYK_ORG_ID }}
--project-name=${{ github.repository }}
--severity-threshold=high
--fail-on=all
- name: Run Snyk on Python
uses: snyk/actions/python@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: monitor
args: >
--org=${{ secrets.SNYK_ORG_ID }}
--project-name=${{ github.repository }}
## TODO: Find out where the test report goes
#########################################################################
# Publish new version numbers
#########################################################################
- name: Quick check for changes
id: check_changes
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release')
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit Version Bump
# If building develop, a release branch, or main then we commit the version bump back to the repo
if: steps.check_changes.outputs.changes == 'true'
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git commit -am "/version ${{ env.new_version }}"
git push
- name: Push Tag
env:
VERSION: ${{ env.new_version }}
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release')
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${VERSION}" -m "Version ${VERSION}"
git push origin "${VERSION}"
#########################################################################
# Publish release to releases
#########################################################################
- name: Create Zip release
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release') ||
github.event.head_commit.message == '/deploy sit' ||
github.event.head_commit.message == '/deploy uat' ||
github.event.head_commit.message == '/deploy sandbox'
run: |
poetry run pip install -t package dist/*.whl
mv package/podaac/hitide_backfill_post_step package
mv package/podaac/hitide_backfill_sqs_to_step package
ls -la
ls -la package
cd package/; zip -r ../terraform/hitide-backfill-lambda.zip . -x '*.pyc'
cd ../; cd terraform; zip -r ../hitide-backfill-lambdas-${{ env.new_version }}.zip *
- name: Upload Release Artifacts
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release') ||
github.event.head_commit.message == '/deploy sit' ||
github.event.head_commit.message == '/deploy uat' ||
github.event.head_commit.message == '/deploy sandbox'
uses: ncipollo/[email protected]
with:
tag: ${{ env.new_version }}
artifacts: "*.zip"
token: ${{ secrets.GITHUB_TOKEN }}
body: "Version ${{ env.new_version }}"
makeLatest: "${{ github.ref == 'refs/heads/main' }}"
prerelease: "${{ github.ref != 'refs/heads/main' }}"