Skip to content

Commit

Permalink
Merge branch 'release/2.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinscham committed Sep 8, 2023
2 parents 0bddfab + 6d51668 commit 697ba35
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,26 @@ on:
- '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: Analyze
needs: env
runs-on: ubuntu-latest
permissions: read-all

Expand All @@ -17,22 +35,13 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Extract tag and pre-release check
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
if [[ "${GITHUB_REF#refs/tags/}" == *-* ]]; then
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "PRERELEASE=false" >> $GITHUB_ENV
fi
- 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=${{ env.VERSION }}
args: -Dsonar.projectVersion=${{ needs.env.outputs.version }}

- name: Quality gate check
uses: sonarsource/sonarqube-quality-gate-action@master
Expand All @@ -42,17 +51,15 @@ jobs:

release:
name: Release
needs: analyze
needs: [env, analyze]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Generate release notes
id: changelog
run: |
CHANGELOG=$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"- %s")
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV
run: echo changelog=$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"- %s") >> "$GITHUB_OUTPUT"

- name: Create Release
id: create_release
Expand All @@ -61,14 +68,14 @@ jobs:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: ${{env.PRERELEASE == 'true'}}
body: ${{ env.CHANGELOG }}
prerelease: ${{ needs.env.outputs.prerelease == 'true' }}
body: ${{ steps.changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GHCR_PAT }}

publish:
name: Publish
needs: release
needs: [env, release]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -85,10 +92,10 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ env.VERSION }}
tags: ghcr.io/${{ github.repository }}:${{ needs.env.outputs.version }}

- name: Build and push latest Docker image
if: env.PRERELEASE == 'false'
if: needs.env.outputs.prerelease == 'false'
uses: docker/build-push-action@v2
with:
push: true
Expand Down

0 comments on commit 697ba35

Please sign in to comment.