From c8d92a7a84e15c55652b329e831d66cf3028ff28 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 8 May 2025 10:31:41 -0800 Subject: [PATCH 1/9] remove reusable-git-object-name workflow --- .../workflows/reusable-git-object-name.yml | 23 ------------ .github/workflows/update-examples.yml | 6 +--- CHANGELOG.md | 5 +++ README.md | 36 +------------------ 4 files changed, 7 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/reusable-git-object-name.yml diff --git a/.github/workflows/reusable-git-object-name.yml b/.github/workflows/reusable-git-object-name.yml deleted file mode 100644 index 3a2f247..0000000 --- a/.github/workflows/reusable-git-object-name.yml +++ /dev/null @@ -1,23 +0,0 @@ -on: - workflow_call: - outputs: - name: - value: ${{ jobs.tag_info.outputs.name }} - - -jobs: - tag_info: - runs-on: ubuntu-latest - outputs: - name: ${{ steps.set_outputs.outputs.name }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: set outputs - id: set_outputs - shell: bash -l {0} - run: | - export SDIST_VERSION=$(git describe --dirty --tags --long --match "*[0-9]*") - echo "name=${SDIST_VERSION}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/update-examples.yml b/.github/workflows/update-examples.yml index f973b8d..6eb46d0 100644 --- a/.github/workflows/update-examples.yml +++ b/.github/workflows/update-examples.yml @@ -12,11 +12,7 @@ on: - v* jobs: - call-git-object-name-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-git-object-name.yml@v0.18.1 - upate_actions_examples: - needs: call-git-object-name-workflow runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,8 +22,8 @@ jobs: - name: Get version number env: INPUT_VERSION: ${{ github.event.inputs.version }} - OBJECT_VERSION: ${{ needs.call-git-object-name-workflow.outputs.name }} run: | + OBJECT_VERSION=$(git describe --dirty --tags --long --match "*[0-9]*") if [[ -z "${INPUT_VERSION}" ]]; then echo "ACTIONS_VERSION=${OBJECT_VERSION%%-*}" >> $GITHUB_ENV else diff --git a/CHANGELOG.md b/CHANGELOG.md index dab9054..0a1d43b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.19.0] + +### Removed +- The `reusable-git-object-name.yml` workflow has been removed. We recommend using the `reusable-version-info.yml` workflow instead. + ## [0.18.1] ### Added diff --git a/README.md b/README.md index c45621e..ad3ac8a 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ Therefore, to determine both the custom field name and the sprint ID, do the fol Builds a Docker image from the `Dockerfile` in the repository root and pushes it to the [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/) -with the specified version tag, and is best paired with either the `reusable-version-info.yml` workflow or the `reusable-git-object-name.yml` workflow. This workflow will +with the specified version tag, and is best paired with either the `reusable-version-info.yml` workflow. This workflow will additionally push the image with a `latest` and `test` tag for merges to the release and develop branch, respectively. Use like: @@ -378,40 +378,6 @@ you should remove the [`check_untyped_defs`](https://mypy.readthedocs.io/en/stab Removing this option can be helpful when adding mypy to an existing codebase with large portions of untyped code, or if you simply want the ability to opt out of static type checking on a per-function basis. -### [`reusable-git-object-name.yml`](./.github/workflows/reusable-git-object-name.yml) - -Outputs the human-readable git object name from [`git describe --dirty --tags --long --match "*[0-9]*"`](https://git-scm.com/docs/git-describe) -of the calling repository. Use like: - -```yaml -name: Build - -on: - push: - branches: - - main - - develop - pull_request: - branches: - - main - - develop - -jobs: - call-git-object-name-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-git-object-name.yml@v0.18.1 - permissions: - contents: read - - echo-git-object-name-outputs: - needs: call-git-object-name-workflow - runs-on: ubuntu-latest - permissions: {} - steps: - - run: | - echo "name: ${{ needs.call-git-object-name-workflow.outputs.name }}" -``` -This workflow is intended to be paired with workflows like the `reusable-docker-ghcr.yml` workflow. - ### [`reusable-labeled-pr-check.yml`](./.github/workflows/reusable-labeled-pr-check.yml) Ensures a PR has been labeled with exactly 1 of these labels: `major`, `minor`, `patch` or `bumpless` to support the From ed585b7008f0dfa1098fedc2057981eb576b4683 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 8 May 2025 10:43:27 -0800 Subject: [PATCH 2/9] try new tagging logic --- .github/workflows/reusable-docker-ghcr.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/reusable-docker-ghcr.yml b/.github/workflows/reusable-docker-ghcr.yml index be0ecdc..35819d0 100644 --- a/.github/workflows/reusable-docker-ghcr.yml +++ b/.github/workflows/reusable-docker-ghcr.yml @@ -4,10 +4,6 @@ on: version_tag: required: true type: string - release_branch: - required: false - default: main - type: string develop_branch: required: false default: develop @@ -24,6 +20,10 @@ on: USER_TOKEN: required: true +concurrency: + group: ${{ inputs.version_tag }} + cancel-in-progress: true + jobs: dockerize: runs-on: ubuntu-latest @@ -64,14 +64,14 @@ jobs: org.opencontainers.image.revision=${{ github.sha }} - name: Add test tag - if: ${{ github.ref == format('refs/heads/{0}', inputs.develop_branch) && ! github.event.pull_request.head.repo.fork }} + if: ${{ github.event_name != 'pull_request' && contains('.dev', inputs.version_tag) }} uses: akhilerm/tag-push-action@v2.2.0 with: src: ghcr.io/${{ env.REPO }}:${{ inputs.version_tag }} dst: ghcr.io/${{ env.REPO }}:test - name: Add latest tag - if: ${{ github.ref == format('refs/heads/{0}', inputs.release_branch) && ! github.event.pull_request.head.repo.fork }} + if: ${{ github.event_name != 'pull_request' && ! contains('.dev', inputs.version_tag) }} uses: akhilerm/tag-push-action@v2.2.0 with: src: ghcr.io/${{ env.REPO }}:${{ inputs.version_tag }} From 16dafa440a21431f23596cba0997ad250a53d180 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 8 May 2025 11:03:58 -0800 Subject: [PATCH 3/9] fix contains expressions --- .github/workflows/reusable-docker-ghcr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-docker-ghcr.yml b/.github/workflows/reusable-docker-ghcr.yml index 35819d0..2feea0b 100644 --- a/.github/workflows/reusable-docker-ghcr.yml +++ b/.github/workflows/reusable-docker-ghcr.yml @@ -64,14 +64,14 @@ jobs: org.opencontainers.image.revision=${{ github.sha }} - name: Add test tag - if: ${{ github.event_name != 'pull_request' && contains('.dev', inputs.version_tag) }} + if: ${{ github.event_name != 'pull_request' && contains(inputs.version_tag, '.dev') }} uses: akhilerm/tag-push-action@v2.2.0 with: src: ghcr.io/${{ env.REPO }}:${{ inputs.version_tag }} dst: ghcr.io/${{ env.REPO }}:test - name: Add latest tag - if: ${{ github.event_name != 'pull_request' && ! contains('.dev', inputs.version_tag) }} + if: ${{ github.event_name != 'pull_request' && ! contains(inputs.version_tag, '.dev') }} uses: akhilerm/tag-push-action@v2.2.0 with: src: ghcr.io/${{ env.REPO }}:${{ inputs.version_tag }} From 6197b205994f65b29c88bfada070a15d7e156efb Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 8 May 2025 12:28:36 -0800 Subject: [PATCH 4/9] reflect GHCR workflow changes in ECR workflow --- .github/workflows/reusable-docker-ecr.yml | 19 ++++++++++------- README.md | 25 +++++++++++++++-------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/reusable-docker-ecr.yml b/.github/workflows/reusable-docker-ecr.yml index 6c83d62..9697f41 100644 --- a/.github/workflows/reusable-docker-ecr.yml +++ b/.github/workflows/reusable-docker-ecr.yml @@ -11,20 +11,24 @@ on: required: false default: us-west-2 type: string - release_branch: - required: false - default: main - type: string develop_branch: required: false default: develop type: string + file: + required: false + default: Dockerfile + type: string secrets: AWS_ACCESS_KEY_ID: required: true AWS_SECRET_ACCESS_KEY: required: true +concurrency: + group: ${{ inputs.version_tag }} + cancel-in-progress: true + jobs: dockerize: runs-on: ubuntu-latest @@ -57,7 +61,8 @@ jobs: uses: docker/build-push-action@v6 with: context: . - push: true + file: ./${{ inputs.file }} + push: ${{ ! github.event.pull_request.head.repo.fork }} tags: | ${{ inputs.ecr_registry }}/${{ env.REPO }}:${{ inputs.version_tag }} labels: | @@ -66,14 +71,14 @@ jobs: org.opencontainers.image.revision=${{ github.sha }} - name: Add test tag - if: github.ref == format('refs/heads/{0}', inputs.develop_branch) + if: ${{ github.event_name != 'pull_request' && contains(inputs.version_tag, '.dev') }} uses: akhilerm/tag-push-action@v2.2.0 with: src: ${{ inputs.ecr_registry }}/${{ env.REPO }}:${{ inputs.version_tag }} dst: ${{ inputs.ecr_registry }}/${{ env.REPO }}:test - name: Add latest tag - if: github.ref == format('refs/heads/{0}', inputs.release_branch) + if: ${{ github.event_name != 'pull_request' && ! contains(inputs.version_tag, '.dev') }} uses: akhilerm/tag-push-action@v2.2.0 with: src: ${{ inputs.ecr_registry }}/${{ env.REPO }}:${{ inputs.version_tag }} diff --git a/README.md b/README.md index ad3ac8a..15e0457 100644 --- a/README.md +++ b/README.md @@ -139,8 +139,11 @@ Therefore, to determine both the custom field name and the sprint ID, do the fol Builds a Docker image from the `Dockerfile` in the repository root and pushes it to the [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/) with the specified version tag, and is best paired with either the `reusable-version-info.yml` workflow. This workflow will -additionally push the image with a `latest` and `test` tag for merges to the release and develop branch, respectively. -Use like: +additionally push the image with a `latest` and `test` tag for releases and pushes to the develop branch, respectively. + +> [!WARNING] +> This action assumes version numbers follow [PEP-440](https://peps.python.org/pep-0440/) and applies the latest tag to +> all [non-developmental](https://peps.python.org/pep-0440/#developmental-releases) versions. ```yaml name: Build @@ -148,8 +151,9 @@ name: Build on: push: branches: - - main - develop + tags: + - 'v*' pull_request: branches: - main @@ -172,8 +176,8 @@ jobs: version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }} ecr_registry: 845172464411.dkr.ecr.us-west-2.amazonaws.com aws_region: us-west-2 # Optional; default shown - release_branch: main # Optional; default shown develop_branch: develop # Optional; default shown + file: Dockerfile # Optional; default shown secrets: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -183,8 +187,13 @@ jobs: Builds a Docker image from the `Dockerfile` in the repository root and pushes it to the [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) -with the specified version tag, and is best paired with the `reusable-version-info.yml` workflow or the `reusable-git-object-name.yml` workflow. This workflow will -additionally push the image with a `latest` and `test` tag for merges to the release and develop branch, respectively. +with the specified version tag, and is best paired with the `reusable-version-info.yml` workflow. This workflow will +additionally push the image with a `latest` and `test` tag for releases and pushes to the develop branch, respectively. + +> [!WARNING] +> This action assumes version numbers follow [PEP-440](https://peps.python.org/pep-0440/) and applies the latest tag to +> all [non-developmental](https://peps.python.org/pep-0440/#developmental-releases) versions. + Use like: ```yaml @@ -193,8 +202,9 @@ name: Build on: push: branches: - - main - develop + tags: + - 'v*' pull_request: branches: - main @@ -217,7 +227,6 @@ jobs: with: version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }} user: ${{ github.actor }} - release_branch: main # Optional; default shown develop_branch: develop # Optional; default shown file: Dockerfile # Optional; default shown secrets: From 034d5f1dc1c02cf487107cc8f35656e8062d5f75 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 8 May 2025 15:51:35 -0800 Subject: [PATCH 5/9] describe changes --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a1d43b..f63304e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,40 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.19.0] +### Added +- The `reusable-docker-ecr.yml` workflow now accepts a `file` input for specifying the name of the dockerfile to build. + +### Changed +- The `update-examples.yml` workflow no longer used the `reusable-git-object-name.yml` workflow. +- The `reusable-docker-ecr.yml` and `reusable-docker-ghcr.yml` workflows have changed substantially! These workflows are now version-centric instead of branch-centric and their usage has changed. Please make these changes to any calling workflow: + ```diff + on: + push: + branches: + - - main + - develop + + tags: + + - 'v*' + pull_request: + branches: + - main + - develop + ``` + + and: + ```diff + uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.19.0 + ... + with: + - release_branch: main + ... + ``` + + For current usage, see the [README](README.md) and for more details about these changes, see https://github.com/ASFHyP3/actions/pull/288. + +### Fixed +- `latest` tagged docker images will now be applied to release-tagged images correctly. + ### Removed - The `reusable-git-object-name.yml` workflow has been removed. We recommend using the `reusable-version-info.yml` workflow instead. From 957d7e3fe9a13f6fbf869ade98120668f3a8acd6 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Fri, 9 May 2025 09:57:11 -0800 Subject: [PATCH 6/9] dockerize workflows don't use the develop_branch anymore either --- .github/workflows/reusable-docker-ecr.yml | 4 ---- .github/workflows/reusable-docker-ghcr.yml | 4 ---- CHANGELOG.md | 1 + README.md | 2 -- 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/reusable-docker-ecr.yml b/.github/workflows/reusable-docker-ecr.yml index 9697f41..6e89906 100644 --- a/.github/workflows/reusable-docker-ecr.yml +++ b/.github/workflows/reusable-docker-ecr.yml @@ -11,10 +11,6 @@ on: required: false default: us-west-2 type: string - develop_branch: - required: false - default: develop - type: string file: required: false default: Dockerfile diff --git a/.github/workflows/reusable-docker-ghcr.yml b/.github/workflows/reusable-docker-ghcr.yml index 2feea0b..5d0ab1b 100644 --- a/.github/workflows/reusable-docker-ghcr.yml +++ b/.github/workflows/reusable-docker-ghcr.yml @@ -4,10 +4,6 @@ on: version_tag: required: true type: string - develop_branch: - required: false - default: develop - type: string user: required: false default: tools-bot diff --git a/CHANGELOG.md b/CHANGELOG.md index f63304e..fa695c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ... with: - release_branch: main + - develop_branch: develop ... ``` diff --git a/README.md b/README.md index 15e0457..9b2681d 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,6 @@ jobs: version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }} ecr_registry: 845172464411.dkr.ecr.us-west-2.amazonaws.com aws_region: us-west-2 # Optional; default shown - develop_branch: develop # Optional; default shown file: Dockerfile # Optional; default shown secrets: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -227,7 +226,6 @@ jobs: with: version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }} user: ${{ github.actor }} - develop_branch: develop # Optional; default shown file: Dockerfile # Optional; default shown secrets: USER_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 81ad555234d282ded859805dfa8c3d7b275b8ad9 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 15 May 2025 11:56:22 -0800 Subject: [PATCH 7/9] Update .github/workflows/update-examples.yml Co-authored-by: Jake Herrmann --- .github/workflows/update-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-examples.yml b/.github/workflows/update-examples.yml index 6eb46d0..7de00ed 100644 --- a/.github/workflows/update-examples.yml +++ b/.github/workflows/update-examples.yml @@ -12,7 +12,7 @@ on: - v* jobs: - upate_actions_examples: + update-actions-examples: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From c52cbb75ceff9ff7afc82fc6337a60486edcb63c Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 15 May 2025 13:49:43 -0800 Subject: [PATCH 8/9] Apply suggestions from code review Co-authored-by: Jake Herrmann --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index edc0304..6b5c87a 100644 --- a/README.md +++ b/README.md @@ -138,11 +138,11 @@ Therefore, to determine both the custom field name and the sprint ID, do the fol Builds a Docker image from the `Dockerfile` in the repository root and pushes it to the [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/) -with the specified version tag, and is best paired with either the `reusable-version-info.yml` workflow. This workflow will -additionally push the image with a `latest` and `test` tag for releases and pushes to the develop branch, respectively. +with the specified version tag, and is best paired with the `reusable-version-info.yml` workflow. This workflow will +additionally push the image with a `latest` tag for releases and a `test` tag for pushes to the develop branch. > [!WARNING] -> This action assumes version numbers follow [PEP-440](https://peps.python.org/pep-0440/) and applies the latest tag to +> This action assumes version numbers follow [PEP-440](https://peps.python.org/pep-0440/) and applies the `latest` tag to > all [non-developmental](https://peps.python.org/pep-0440/#developmental-releases) versions. ```yaml @@ -187,10 +187,10 @@ jobs: Builds a Docker image from the `Dockerfile` in the repository root and pushes it to the [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) with the specified version tag, and is best paired with the `reusable-version-info.yml` workflow. This workflow will -additionally push the image with a `latest` and `test` tag for releases and pushes to the develop branch, respectively. +additionally push the image with a `latest` tag for releases and a `test` tag for pushes to the develop branch. > [!WARNING] -> This action assumes version numbers follow [PEP-440](https://peps.python.org/pep-0440/) and applies the latest tag to +> This action assumes version numbers follow [PEP-440](https://peps.python.org/pep-0440/) and applies the `latest` tag to > all [non-developmental](https://peps.python.org/pep-0440/#developmental-releases) versions. Use like: From 2472b8b4968d114f762a256f65efd2d5f67c7410 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 15 May 2025 15:15:56 -0800 Subject: [PATCH 9/9] Apply suggestions from code review Co-authored-by: Jake Herrmann --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e53838..03075a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). For current usage, see the [README](README.md) and for more details about these changes, see https://github.com/ASFHyP3/actions/pull/288. ### Fixed -- `latest` tagged docker images will now be applied to release-tagged images correctly. +- `latest` tag will now be applied to release-tagged Docker images correctly. Fixes https://github.com/ASFHyP3/actions/issues/278 ### Removed - The `reusable-git-object-name.yml` workflow has been removed. We recommend using the `reusable-version-info.yml` workflow instead.