chore(deps): move upgrade of ContainerBaseImage into shared Renovate … #27
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: Combined CI / Release | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
branches: | |
- '**' | |
env: | |
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }} | |
jobs: | |
ci_cd: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up .NET | |
uses: actions/setup-dotnet@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Begin Sonar scan | |
run: | | |
dotnet tool install --global dotnet-sonarscanner | |
dotnet sonarscanner begin /k:mu88_RaspiFanController /o:mu88 /d:sonar.token=${{ secrets.SONAR_TOKEN }} /d:sonar.host.url=https://sonarcloud.io /d:sonar.cs.opencover.reportsPaths=Tests/coverage.opencover.xml /s:$GITHUB_WORKSPACE/SonarQube.Analysis.xml | |
- name: .NET Build | |
run: dotnet build --no-restore | |
- name: Test and collect coverage | |
run: dotnet test --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | |
- name: End Sonar scan | |
run: dotnet sonarscanner end /d:sonar.token=${{ secrets.SONAR_TOKEN }} | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
registry: registry.hub.docker.com | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Write release version | |
if: ${{ env.IS_RELEASE == 'true' }} | |
run: | | |
VERSION=${GITHUB_REF_NAME#v} | |
echo Version: $VERSION | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Build and push Docker non-release | |
if: ${{ env.IS_RELEASE != 'true' }} | |
run: | | |
dotnet publish RaspiFanController/RaspiFanController.csproj /t:MultiArchPublish '-p:ContainerImageTags="dev"' -p:ContainerRegistry=registry.hub.docker.com | |
dotnet publish RaspiFanController/RaspiFanController.csproj /t:MultiArchPublish '-p:ContainerImageTags="dev-chiseled"' -p:ContainerFamily=jammy-chiseled -p:ContainerRegistry=registry.hub.docker.com | |
- name: Build and push Docker release | |
if: ${{ env.IS_RELEASE == 'true' }} | |
run: | | |
dotnet publish RaspiFanController/RaspiFanController.csproj /t:MultiArchPublish '-p:ContainerImageTags="${{ env.VERSION }};latest"' -p:ContainerRegistry=registry.hub.docker.com | |
dotnet publish RaspiFanController/RaspiFanController.csproj /t:MultiArchPublish '-p:ContainerImageTags="${{ env.VERSION }}-chiseled;latest-chiseled"' -p:ContainerRegistry=registry.hub.docker.com -p:ContainerFamily=jammy-chiseled | |
- name: .NET Publish | |
run: dotnet publish RaspiFanController/RaspiFanController.csproj -r linux-arm64 /p:PublishSingleFile=true --self-contained | |
- name: Create artifact | |
if: ${{ env.IS_RELEASE == 'true' }} | |
run: | | |
cd /home/runner/work/RaspiFanController/RaspiFanController/RaspiFanController/bin/Release/net8.0/linux-arm64/publish | |
zip -r RaspiFanController.zip * | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
if: ${{ env.IS_RELEASE == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Upload asset to GitHub Release | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
if: ${{ env.IS_RELEASE == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: /home/runner/work/RaspiFanController/RaspiFanController/RaspiFanController/bin/Release/net8.0/linux-arm64/publish/RaspiFanController.zip | |
asset_name: RaspiFanController.zip | |
asset_content_type: application/zip |