Add versioning support for image tags
This commit is contained in:
48
.github/workflows/cd.yml
vendored
48
.github/workflows/cd.yml
vendored
@@ -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 }}
|
||||
|
||||
2
.github/workflows/example.yml
vendored
2
.github/workflows/example.yml
vendored
@@ -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
|
||||
|
||||
|
||||
4
.github/workflows/version-check.yml
vendored
4
.github/workflows/version-check.yml
vendored
@@ -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 }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user