fix: create init tag #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create and publish a Docker image | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Get Next Semver Version | |
id: semver | |
uses: ietf-tools/[email protected] | |
with: | |
token: ${{ github.token }} | |
branch: main | |
noVersionBumpBehavior: warn | |
- name: Create Tag | |
uses: rickstaa/[email protected] | |
if: ${{ steps.semver.outputs.nextStrict != '' }} | |
with: | |
tag: ${{ steps.semver.outputs.nextStrict }} | |
tag_exists_error: false | |
message: "Automatic tag ${{ steps.semver.outputs.nextStrict }}" | |
- name: Update CHANGELOG | |
id: changelog | |
uses: requarks/[email protected] | |
if: ${{ steps.semver.outputs.nextStrict != '' }} | |
with: | |
token: ${{ github.token }} | |
fromTag: ${{ steps.semver.outputs.nextStrict }} | |
toTag: ${{ steps.semver.outputs.current }} | |
excludeTypes: "chore,ci,docs,style,test,release" | |
- name: Create Release | |
uses: ncipollo/[email protected] | |
id: release | |
if: ${{ steps.semver.outputs.nextStrict != '' }} | |
with: | |
allowUpdates: true | |
draft: false | |
makeLatest: true | |
name: ${{ steps.semver.outputs.nextStrict }} | |
tag: ${{ steps.semver.outputs.nextStrict }} | |
body: ${{ steps.changelog.outputs.changes }} | |
token: ${{ github.token }} | |
- name: Commit CHANGELOG.md | |
uses: stefanzweifel/[email protected] | |
if: ${{ steps.semver.outputs.nextStrict != '' }} | |
with: | |
branch: main | |
commit_message: "release: changelog for ${{ steps.semver.outputs.nextStrict }} [skip ci]" | |
file_pattern: CHANGELOG.md | |
# Workaround: https://github.com/docker/build-push-action/issues/461 | |
- name: Setup Docker buildx | |
uses: docker/[email protected] | |
- name: Log in to the Container registry | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
id: push | |
uses: docker/[email protected] | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.semver.outputs.nextStrict }} | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} |