Skip to content

Tag the correct commit #28

Tag the correct commit

Tag the correct commit #28

Workflow file for this run

name: Build
on:
push:
branches: [ master, main, develop ]
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gitversion.outputs.semVer }}
major: ${{ steps.gitversion.outputs.major }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
configFilePath: ./gitversion.yml
- name: Display SemVer
run: |
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
docker:
runs-on: ubuntu-latest
needs: version
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Lowercase Repository
run: |
echo "REPOSITORY_LC=${REPOSITORY,,}" >>${GITHUB_ENV}
env:
REPOSITORY: '${{ github.repository }}'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.REPOSITORY_LC }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ steps.meta.outputs.tags }}
ghcr.io/${{ env.REPOSITORY_LC }}:latest
ghcr.io/${{ env.REPOSITORY_LC }}:${{ needs.version.outputs.version }}
update-image:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
outputs:
commit_hash: ${{ steps.auto-commit.outputs.commit_hash }}
needs:
- docker
- version
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Lowercase Repository
run: |
echo "REPOSITORY_LC=${REPOSITORY,,}" >>${GITHUB_ENV}
env:
REPOSITORY: '${{ github.repository }}'
- name: Render template
id: render_template
uses: chuhlomin/render-template@v1
with:
template: templates/action.template.yml
result_path: action.yml
vars: |
image: docker://ghcr.io/${{ env.REPOSITORY_LC }}:${{ needs.version.outputs.version }}
- name: Update README.md
uses: emilymclean/[email protected]
env:
ACTION_REPO: ${{ github.repository }}
ACTION_VERSION: ${{ needs.version.outputs.major }}
with:
template-file: templates/README.template.md
output-file: README.md
engine: mustache
- uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit
with:
commit_message: "Update metadata for ${{ github.event.commits[0].message }}"
release-main:
runs-on: ubuntu-latest
needs:
- version
- update-image
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
if: github.event_name != 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create tag for release
uses: rickstaa/action-create-tag@v1
with:
tag: v${{ needs.version.outputs.version }}
commit_sha: ${{ needs.update-image.outputs.commit_hash }}
- id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.version.outputs.version }}
name: Release ${{ needs.version.outputs.version }}
prerelease: ${{ github.ref == 'refs/heads/develop' }}
- uses: jimeh/update-tags-action@v1
if: github.ref == 'refs/heads/main'
with:
tags: v${{ needs.version.outputs.major }}
release-other:
runs-on: ubuntu-latest
needs:
- version
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create tag for release
uses: rickstaa/action-create-tag@v1
with:
tag: v${{ needs.version.outputs.version }}
- id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.version.outputs.version }}
name: Release ${{ needs.version.outputs.version }}
prerelease: ${{ github.ref == 'refs/heads/develop' }}