From 2a734a52a35efecc877ae7f5cf818859af5ef17b Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 22 Aug 2024 12:37:50 -0400 Subject: [PATCH] Add versioning support for image tags --- .github/workflows/cd.yml | 48 +++++++++-------------------- .github/workflows/example.yml | 2 +- .github/workflows/version-check.yml | 4 +-- .version | 1 - action.yml | 2 +- 5 files changed, 19 insertions(+), 38 deletions(-) delete mode 100644 .version diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index cc311d6..ac0169e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -15,27 +15,22 @@ env: CONTAINER_REGISTRY: ghcr.io CONTAINER_REGISTRY_USERNAME: ${{ github.actor }} CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - MANIFEST_PATH: .version + MANIFEST_PATH: action.yml permissions: contents: write packages: write jobs: - release: - name: Create Release + publish: + name: Publish Container Image runs-on: ubuntu-latest # Ignore Dependabot pull requests. if: | github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && - github.event.pull_request.user.login != 'dependabot[bot]') - - outputs: - # Semantic version to use for tagging container images. - # E.g. `1.2.3` or `1.2.3-alpha.4` - version: ${{ steps.tag.outputs.version }} + startsWith(github.head_ref, 'dependabot/') == false) steps: - name: Checkout @@ -45,34 +40,15 @@ jobs: fetch-tags: true ref: main - - name: Tag Version - id: tag - uses: issue-ops/semver@v2.0.0 + - name: Check Version + id: version + uses: issue-ops/semver@v2 with: + check-only: true manifest-path: ${{ env.MANIFEST_PATH }} ref: main workspace: ${{ github.workspace }} - - name: Create Release - id: release - uses: issue-ops/releaser@v2.0.0 - with: - tag: v${{ steps.tag.outputs.version }} - - publish: - name: Publish Container Image - runs-on: ubuntu-latest - - needs: release - - steps: - - name: Checkout - id: checkout - uses: actions/checkout@v4 - with: - fetch-tags: true - ref: main - # Create the list of image tags that will be published. If a prerelease is # being published (e.g. `1.2.3-alpha.4`), only the prerelease tag will be # published (`v1.2.3-alpha.4`). Otherwise, the following tags will be @@ -86,7 +62,7 @@ jobs: uses: actions/github-script@v7 with: script: | - const version = '${{ needs.release.outputs.version }}' + const version = '${{ steps.version.outputs.version }}' // Check if prerelease (e.g. 1.2.3-alpha.4) if (version.includes('-')) { @@ -131,3 +107,9 @@ jobs: labels: ${{ env.LABELS }} push: true tags: ${{ env.TAGS }} + + - name: Create Release + id: release + uses: issue-ops/releaser@v2 + with: + tag: v${{ steps.version.outputs.version }} diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index e331542..2482cce 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Run the Container Action id: run - uses: actions/container-prebuilt-action@v0.1.0 + uses: actions/container-prebuilt-action@v0.2.0 with: who-to-greet: Mona Lisa Octocat diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml index 23efd8b..6a1eb67 100644 --- a/.github/workflows/version-check.yml +++ b/.github/workflows/version-check.yml @@ -10,7 +10,7 @@ on: - main env: - MANIFEST_PATH: .version + MANIFEST_PATH: action.yml permissions: checks: write @@ -33,7 +33,7 @@ jobs: - name: Check Version id: check-version - uses: issue-ops/semver@v2.0.0 + uses: issue-ops/semver@v2 with: check-only: true manifest-path: ${{ env.MANIFEST_PATH }} diff --git a/.version b/.version deleted file mode 100644 index 6c6aa7c..0000000 --- a/.version +++ /dev/null @@ -1 +0,0 @@ -0.1.0 \ No newline at end of file diff --git a/action.yml b/action.yml index b6348b4..b869f5c 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,6 @@ outputs: # Update the image repository and tag below. runs: using: docker - image: docker://ghcr.io/actions/container-prebuilt-action:latest + image: docker://ghcr.io/actions/container-prebuilt-action:v0.2.0 env: INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }}