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: ghcr.io
|
||||||
CONTAINER_REGISTRY_USERNAME: ${{ github.actor }}
|
CONTAINER_REGISTRY_USERNAME: ${{ github.actor }}
|
||||||
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||||
MANIFEST_PATH: .version
|
MANIFEST_PATH: action.yml
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
publish:
|
||||||
name: Create Release
|
name: Publish Container Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# Ignore Dependabot pull requests.
|
# Ignore Dependabot pull requests.
|
||||||
if: |
|
if: |
|
||||||
github.event_name == 'workflow_dispatch' ||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
(github.event.pull_request.merged == true &&
|
(github.event.pull_request.merged == true &&
|
||||||
github.event.pull_request.user.login != 'dependabot[bot]')
|
startsWith(github.head_ref, 'dependabot/') == false)
|
||||||
|
|
||||||
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 }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -45,34 +40,15 @@ jobs:
|
|||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
ref: main
|
ref: main
|
||||||
|
|
||||||
- name: Tag Version
|
- name: Check Version
|
||||||
id: tag
|
id: version
|
||||||
uses: issue-ops/semver@v2.0.0
|
uses: issue-ops/semver@v2
|
||||||
with:
|
with:
|
||||||
|
check-only: true
|
||||||
manifest-path: ${{ env.MANIFEST_PATH }}
|
manifest-path: ${{ env.MANIFEST_PATH }}
|
||||||
ref: main
|
ref: main
|
||||||
workspace: ${{ github.workspace }}
|
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
|
# 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
|
# 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
|
# published (`v1.2.3-alpha.4`). Otherwise, the following tags will be
|
||||||
@@ -86,7 +62,7 @@ jobs:
|
|||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const version = '${{ needs.release.outputs.version }}'
|
const version = '${{ steps.version.outputs.version }}'
|
||||||
|
|
||||||
// Check if prerelease (e.g. 1.2.3-alpha.4)
|
// Check if prerelease (e.g. 1.2.3-alpha.4)
|
||||||
if (version.includes('-')) {
|
if (version.includes('-')) {
|
||||||
@@ -131,3 +107,9 @@ jobs:
|
|||||||
labels: ${{ env.LABELS }}
|
labels: ${{ env.LABELS }}
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ env.TAGS }}
|
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:
|
steps:
|
||||||
- name: Run the Container Action
|
- name: Run the Container Action
|
||||||
id: run
|
id: run
|
||||||
uses: actions/container-prebuilt-action@v0.1.0
|
uses: actions/container-prebuilt-action@v0.2.0
|
||||||
with:
|
with:
|
||||||
who-to-greet: Mona Lisa Octocat
|
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
|
- main
|
||||||
|
|
||||||
env:
|
env:
|
||||||
MANIFEST_PATH: .version
|
MANIFEST_PATH: action.yml
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
checks: write
|
checks: write
|
||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Check Version
|
- name: Check Version
|
||||||
id: check-version
|
id: check-version
|
||||||
uses: issue-ops/semver@v2.0.0
|
uses: issue-ops/semver@v2
|
||||||
with:
|
with:
|
||||||
check-only: true
|
check-only: true
|
||||||
manifest-path: ${{ env.MANIFEST_PATH }}
|
manifest-path: ${{ env.MANIFEST_PATH }}
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ outputs:
|
|||||||
# Update the image repository and tag below.
|
# Update the image repository and tag below.
|
||||||
runs:
|
runs:
|
||||||
using: docker
|
using: docker
|
||||||
image: docker://ghcr.io/actions/container-prebuilt-action:latest
|
image: docker://ghcr.io/actions/container-prebuilt-action:v0.2.0
|
||||||
env:
|
env:
|
||||||
INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }}
|
INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }}
|
||||||
|
|||||||
Reference in New Issue
Block a user