Merge pull request #10 from marvinscham/develop #10
Workflow file for this run
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: Analyze, Release and Publish to GHCR | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
- 'v*.*.*-*' | |
jobs: | |
env: | |
name: Prepare environment | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{steps.version.outputs.version}} | |
prerelease: ${{steps.prerelease.outputs.prerelease}} | |
steps: | |
- id: version | |
run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | |
- id: prerelease | |
run: | | |
if [[ "${GITHUB_REF#refs/tags/}" == *-* ]]; then | |
echo "prerelease=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "prerelease=false" >> "$GITHUB_OUTPUT" | |
fi | |
analyze: | |
name: Pre-build Analysis | |
needs: env | |
runs-on: ubuntu-latest | |
permissions: read-all | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: SonarQube scan | |
uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
with: | |
args: -Dsonar.projectVersion=${{ needs.env.outputs.version }} | |
- name: Quality gate check | |
uses: sonarsource/sonarqube-quality-gate-action@master | |
timeout-minutes: 5 | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
release: | |
name: Release | |
needs: [env, analyze] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build Changelog | |
id: changelog | |
uses: mikepenz/release-changelog-builder-action@v3 | |
with: | |
configuration: '.github/changelog-configuration.json' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GHCR_PAT }} | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ github.ref }} | |
name: Release ${{ needs.env.outputs.version }} | |
draft: false | |
prerelease: ${{ needs.env.outputs.prerelease == 'true' }} | |
body: ${{ steps.changelog.outputs.changelog }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GHCR_PAT }} | |
publish: | |
name: Publish to GHCR | |
needs: [env, release] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GHCR_PAT }} | |
- name: Build and push version-tagged Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ghcr.io/${{ github.repository }}:${{ needs.env.outputs.version }} | |
- name: Build and push latest Docker image | |
if: needs.env.outputs.prerelease == 'false' | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ghcr.io/${{ github.repository }}:latest |