Revert "upgraded to python 10" #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push events | |
push: | |
branches: [ develop, release/**, main, feature/** ] | |
# 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: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v3 | |
with: | |
python-version: 3.9 | |
- name: Install Poetry | |
uses: abatilo/[email protected] | |
with: | |
poetry-version: 1.5.1 | |
- name: Get version | |
id: get-version | |
run: | | |
echo "::set-output name=current_version::$(poetry version | awk '{print $2}')" | |
echo "pyproject_name=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV | |
- name: Bump pre-alpha version | |
# If triggered by push to a feature branch | |
if: ${{ startsWith(github.ref, 'refs/heads/feature/') }} | |
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' }} | |
run: | | |
poetry version prerelease | |
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV | |
echo "venue=sit" >> $GITHUB_ENV | |
- name: Bump rc version | |
# If triggered by push to a release branch | |
if: ${{ startsWith(github.ref, 'refs/heads/release/') }} | |
env: | |
# True if the version already has a 'rc' pre-release identifier | |
BUMP_RC: ${{ contains(steps.get-version.outputs.current_version, 'rc') }} | |
run: | | |
if [ "$BUMP_RC" = true ]; then | |
poetry version prerelease | |
else | |
poetry version ${GITHUB_REF#refs/heads/release/}-rc.1 | |
fi | |
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV | |
echo "venue=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. | |
run: | | |
poetry version ${CURRENT_VERSION%%-rc.*} | |
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV | |
echo "venue=ops" >> $GITHUB_ENV | |
- name: Install cumulus-file-rename | |
run: poetry install | |
- name: Test and coverage | |
run: poetry run pytest --cov cumulus_file_rename tests -v | |
- name: pyLint & flake8 | |
run: | | |
poetry run pylint --exit-zero cumulus_file_rename | |
poetry run flake8 --ignore=E501,W503,W504 cumulus_file_rename | |
- name: Run Snyk on Python | |
uses: snyk/actions/python-3.9@master | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
with: | |
command: monitor | |
args: > | |
-d | |
--org=${{ secrets.SNYK_ORG_ID }} | |
--project-name=${{ github.repository }} | |
- name: Commit Version Bump | |
# If building develop, a release branch, or main 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') | |
run: | | |
git config --global user.name 'concise bot' | |
git config --global user.email '[email protected]' | |
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') | |
run: | | |
tag=${{ env.software_version }} | |
message="Version ${{ env.software_version }}" | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git tag -a "${tag}" -m "${message}" | |
git push origin "${tag}" | |
- name: Build Python Lambda Artifact | |
run: sh ./build.sh | |
- name: Prepare Artifacts | |
run: | | |
artifact_file_name="${{ env.pyproject_name }}-${{ env.software_version }}.zip" | |
echo "ARTIFACT_FILE=$artifact_file_name" >> $GITHUB_ENV | |
mv artifact.zip $artifact_file_name | |
- name: Create PreRelease | |
id: create_prerelease | |
if: ${{ !contains(github.ref, 'master') }} | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: "v${{ env.software_version }}" | |
release_name: "Release v${{ env.software_version }} - ${{ github.ref }}" | |
body: | | |
Changes in this release: | |
${{ github.event.head_commit.message }} | |
draft: false | |
prerelease: true | |
- name: Upload PreRelease Asset | |
id: upload-prerelease-asset | |
if: ${{ !contains(github.ref, 'master') }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_prerelease.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: "${{ env.ARTIFACT_FILE }}" | |
asset_name: "${{ env.ARTIFACT_FILE }}" | |
asset_content_type: application/zip |