diff --git a/.github/workflows/reusable-docker-ecr.yml b/.github/workflows/reusable-docker-ecr.yml index 6c83d62..6e89906 100644 --- a/.github/workflows/reusable-docker-ecr.yml +++ b/.github/workflows/reusable-docker-ecr.yml @@ -11,13 +11,9 @@ on: required: false default: us-west-2 type: string - release_branch: + file: required: false - default: main - type: string - develop_branch: - required: false - default: develop + default: Dockerfile type: string secrets: AWS_ACCESS_KEY_ID: @@ -25,6 +21,10 @@ on: AWS_SECRET_ACCESS_KEY: required: true +concurrency: + group: ${{ inputs.version_tag }} + cancel-in-progress: true + jobs: dockerize: runs-on: ubuntu-latest @@ -57,7 +57,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 +67,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/.github/workflows/reusable-docker-ghcr.yml b/.github/workflows/reusable-docker-ghcr.yml index be0ecdc..5d0ab1b 100644 --- a/.github/workflows/reusable-docker-ghcr.yml +++ b/.github/workflows/reusable-docker-ghcr.yml @@ -4,14 +4,6 @@ on: version_tag: required: true type: string - release_branch: - required: false - default: main - type: string - develop_branch: - required: false - default: develop - type: string user: required: false default: tools-bot @@ -24,6 +16,10 @@ on: USER_TOKEN: required: true +concurrency: + group: ${{ inputs.version_tag }} + cancel-in-progress: true + jobs: dockerize: runs-on: ubuntu-latest @@ -64,14 +60,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(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.ref == format('refs/heads/{0}', inputs.release_branch) && ! github.event.pull_request.head.repo.fork }} + 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 }} 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..7de00ed 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 + update-actions-examples: 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 f2424f9..03075a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,46 @@ 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.20.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 + - develop_branch: develop + ... + ``` + + 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` 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. + ## [0.19.0] ### Added diff --git a/README.md b/README.md index 95d77b4..6b5c87a 100644 --- a/README.md +++ b/README.md @@ -138,9 +138,12 @@ 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 -additionally push the image with a `latest` and `test` tag for merges to the release and develop branch, respectively. -Use like: +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 +> 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,7 @@ 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 +186,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` 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 +> all [non-developmental](https://peps.python.org/pep-0440/#developmental-releases) versions. + Use like: ```yaml @@ -193,8 +201,9 @@ name: Build on: push: branches: - - main - develop + tags: + - 'v*' pull_request: branches: - main @@ -217,8 +226,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: USER_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -382,40 +389,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.19.0 - 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