Skip to content

Commit

Permalink
Merge pull request #28 from podaac/release/0.7.0
Browse files Browse the repository at this point in the history
Release/0.7.0
  • Loading branch information
frankinspace authored Apr 1, 2024
2 parents 1cd41a0 + e765820 commit 1b2f897
Show file tree
Hide file tree
Showing 10 changed files with 402 additions and 587 deletions.
130 changes: 95 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,100 @@
name: Build
# Controls when the workflow will run
on:
# Triggers the workflow on push events
# Triggers the workflow on push events
push:
branches: [ develop, release/**, main, feature/** ]
branches:
- main
- develop
- 'release/**'
- 'feature/**'
- 'issue/**'
- 'issues/**'
- 'dependabot/**'
tags-ignore:
- '*'
# Do not trigger build if pyproject.toml was the only thing changed
paths-ignore:
- 'pyproject.toml'
- 'poetry.lock'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


env:
POETRY_VERSION: "1.7.1"
PYTHON_VERSION: "3.10"

jobs:
# First job in the workflow installs and verifies the software
build:
name: Build, Test, Verify, Tag
# The type of runner that the job will run on
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: getsentry/action-github-app-token@v3
name: podaac cicd token
id: podaac-cicd
with:
app_id: ${{ secrets.CICD_APP_ID }}
private_key: ${{ secrets.CICD_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
python-version: 3.9
repository: ${{ github.repository }}
token: ${{ steps.podaac-cicd.outputs.token }}
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: abatilo/actions-poetry@v2
uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Setup a local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v4
name: Define a cache for the virtual environment based on the dependencies lock file
with:
poetry-version: 1.5.1
- name: Get version
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Get pre-build version
id: get-version
run: |
echo "current_version=$(poetry version | awk '{print $2}')" >> $GITHUB_OUTPUT
echo "pyproject_name=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
- name: Manual Build
# If triggered by workflow dispatch, no version bump
if: github.event_name == 'workflow_dispatch'
id: manual
run: |
echo "workflow_dispatch"
- name: Bump pre-alpha version
# If triggered by push to a feature branch
if: ${{ startsWith(github.ref, 'refs/heads/feature/') }}
# If triggered by push to a non-tracked branch
if: |
github.ref != 'refs/heads/develop' &&
github.ref != 'refs/heads/main'
run: |
new_ver="${{ steps.get-version.outputs.current_version }}+$(git rev-parse --short ${GITHUB_SHA})"
poetry version $new_ver
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
- name: Bump alpha version
# If triggered by push to the develop branch
if: ${{ github.ref == 'refs/heads/develop' }}
if: |
github.ref == 'refs/heads/develop' &&
steps.manual.conclusion == 'skipped'
id: alpha
run: |
poetry version prerelease
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
echo "extra_tag=sit" >> $GITHUB_ENV
- name: Bump rc version
# If triggered by push to a release branch
if: ${{ startsWith(github.ref, 'refs/heads/release/') }}
if: |
startsWith(github.ref, 'refs/heads/release/') &&
steps.manual.conclusion == 'skipped'
id: rc
env:
# True if the version already has a 'rc' pre-release identifier
BUMP_RC: ${{ contains(steps.get-version.outputs.current_version, 'rc') }}
Expand All @@ -56,20 +105,20 @@ jobs:
else
poetry version ${GITHUB_REF#refs/heads/release/}rc1
fi
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
echo "extra_tag=uat" >> $GITHUB_ENV
- name: Release version
# If triggered by push to the main branch
if: ${{ startsWith(github.ref, 'refs/heads/main') }}
env:
CURRENT_VERSION: ${{ steps.get-version.outputs.current_version }}
# Remove -rc.* from end of version string
# The ${string%%substring} syntax below deletes the longest match of $substring from back of $string.
if: |
startsWith(github.ref, 'refs/heads/main') &&
steps.manual.conclusion == 'skipped'
id: release
run: |
poetry version major
echo "TARGET_ENV_UPPERCASE=OPS" >> $GITHUB_ENV
- name: Get install version
# Get the version of the software being installed and save it as an ENV var
run: |
poetry version ${CURRENT_VERSION%%rc*}
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
echo "extra_tag=ops" >> $GITHUB_ENV
- name: Install cmr-umm-publisher
- name: Install package
run: poetry install
- name: Lint
run: |
Expand All @@ -80,23 +129,34 @@ jobs:
run: |
poetry run pytest --junitxml=build/reports/pytest.xml --cov=podaac/ --cov-report=xml:build/reports/coverage.xml -m "not aws and not integration" tests/
- name: Commit Version Bump
# If building develop, a release branch, or main then we commit the version bump back to the repo
# If building an alpha, release candidate, or release then we commit the version bump back to the repo
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release')
steps.alpha.conclusion == 'success' ||
steps.rc.conclusion == 'success' ||
steps.release.conclusion == 'success'
run: |
git config --global user.name 'cmr-umm-publisher bot'
git config --global user.email 'podaac/cmr-umm-updater@noreply.github.com'
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git commit -am "/version ${{ env.software_version }}"
git push
- name: Push Tag
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release')
steps.alpha.conclusion == 'success' ||
steps.rc.conclusion == 'success' ||
steps.release.conclusion == 'success'
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${{ env.software_version }}" -m "Version ${{ env.software_version }}"
git push origin "${{ env.software_version }}"
- name: Create GH release
if: |
steps.alpha.conclusion == 'success' ||
steps.rc.conclusion == 'success' ||
steps.release.conclusion == 'success'
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
name: ${{ env.software_version }}
prerelease: ${{ steps.alpha.conclusion == 'success' || steps.rc.conclusion == 'success'}}
tag: ${{ env.software_version }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security

## [0.7.0]

### Added
- [issues/26](https://github.com/podaac/cmr-umm-updater/issues/26) Add `url_value` input parameter to allow for dynamic values in the `.URL.URLValue` umm record

## [0.6.0]

### Added
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Base container image used for both build and runtime
FROM python:3.9-slim AS base
FROM python:3.12-slim AS base

SHELL ["/bin/bash", "-c"]

Expand All @@ -15,7 +15,7 @@ FROM base as builder
# Disable pip version check and cache, set poetry version
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.2.0
POETRY_VERSION=1.7.1

# Build code using poetry
RUN apt-get install -y --no-install-recommends gcc
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ Either update a umm-s or umm-t in umm defaults to umm-s
### `use_associations`
To use a association file to add collections to umm

### `umm_version`
Version of the umm schema to use during updates. Defaults to '1.3.4'

### `url_value`
Value to substitute for the `.URL.URLValue` key in the umm record. Defaults to environment specific harmony URL

## Environment variables

**Required** Either cmr_user and cmr_pass or token for each environment `sit` `uat` `ops`
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ inputs:
required: false
default: ''
type: string
url_value:
description: "Value to substitute for the `.URL.URLValue` key in the umm record. Defaults to environment specific harmony URL"
required: false
default: ''
type: string

runs:
using: 'docker'
Expand All @@ -69,4 +74,5 @@ runs:
- ${{inputs.umm_type}}
- ${{inputs.use_associations}}
- ${{inputs.umm_version}}
- ${{inputs.url_value}}

14 changes: 11 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ disable_removal=$6
umm_type=$7
use_associations=${8:-true}
umm_version=$9
url_value=$10

# Replace version placeholder with actual version
jq --arg a $version '.Version = $a' "$file" > "cmr/cmr.json"

# Replace Harmony URL placeholder with Harmony URL based on env
if [[ $env == "sit" || $env == "uat" ]]; then
jq --arg a "https://harmony.uat.earthdata.nasa.gov" '.URL.URLValue = $a' cmr/cmr.json > cmr/cmr.json.tmp && mv cmr/cmr.json.tmp cmr/cmr.json
if [[ -n "${url_value}"]]
if [[ $url_value ]]; then
jq --arg a "${url_value}" '.URL.URLValue = $a' cmr/cmr.json > cmr/cmr.json.tmp && mv cmr/cmr.json.tmp cmr/cmr.json
else
# Replace Harmony URL placeholder with Harmony URL based on env
if [[ $env == "sit" || $env == "uat" ]]; then
jq --arg a "https://harmony.uat.earthdata.nasa.gov" '.URL.URLValue = $a' cmr/cmr.json > cmr/cmr.json.tmp && mv cmr/cmr.json.tmp cmr/cmr.json
fi
fi



launchpad_token=""
if [[ $env == "sit" && -n "${LAUNCHPAD_TOKEN_SIT}" ]]; then
launchpad_token=$LAUNCHPAD_TOKEN_SIT
Expand Down
2 changes: 1 addition & 1 deletion podaac/umms_updater/umms_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def parse_args():
default="1.3.4")

args = parser.parse_args()
if not args.token and not(args.cmr_pass and args.cmr_user):
if not args.token and not (args.cmr_pass and args.cmr_user):
parser.error('No credentials provided, add -t or -cu and -cp')
return args

Expand Down
2 changes: 1 addition & 1 deletion podaac/ummt_updater/ummt_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def parse_args():
default="1.0")

args = parser.parse_args()
if not args.token and not(args.cmr_pass and args.cmr_user):
if not args.token and not (args.cmr_pass and args.cmr_user):
parser.error('No credentials provided, add -t or -cu and -cp')
return args

Expand Down
Loading

0 comments on commit 1b2f897

Please sign in to comment.