Fix for docker build. #27
This file contains hidden or 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: Build and Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - develop | |
| - 'feature/**' | |
| - 'release/**' | |
| - 'hotfix/**' | |
| pull_request: | |
| branches: | |
| - master | |
| - develop | |
| env: | |
| DOTNET_VERSION: '8.0.x' | |
| CONFIGURATION: Release | |
| jobs: | |
| build-windows: | |
| name: Build Papercut SMTP | |
| runs-on: windows-2022 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required for GitVersion | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v4.1.0 | |
| with: | |
| versionSpec: '6.x' | |
| - name: Determine Version | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v4.1.0 | |
| with: | |
| configFilePath: GitVersion.yml | |
| - name: Display GitVersion outputs | |
| run: | | |
| echo "SemVer: ${{ steps.gitversion.outputs.semVer }}" | |
| echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}" | |
| echo "BranchName: ${{ steps.gitversion.outputs.branchName }}" | |
| - name: Run Cake Build | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| pwsh .\build.ps1 | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: papercut-releases-${{ steps.gitversion.outputs.fullSemVer }} | |
| path: releases/* | |
| if-no-files-found: warn | |
| - name: Attach Service artifacts to release (master only) | |
| if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.gitversion.outputs.semVer }} | |
| files: releases/Papercut.Smtp.Service.*.zip | |
| fail_on_unmatched_files: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Attach Service artifacts to pre-release (develop only) | |
| if: github.ref == 'refs/heads/develop' && github.event_name == 'push' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.gitversion.outputs.semVer }} | |
| files: releases/Papercut.Smtp.Service.*.zip | |
| fail_on_unmatched_files: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-docker: | |
| name: Build and Push Docker Image | |
| runs-on: ubuntu-latest | |
| needs: build-windows | |
| if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop') && github.event_name == 'push' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v4.1.0 | |
| with: | |
| versionSpec: '6.x' | |
| - name: Determine Version | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v4.1.0 | |
| with: | |
| configFilePath: GitVersion.yml | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: changemakerstudios/papercut-smtp | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/develop' }} | |
| type=raw,value=${{ steps.gitversion.outputs.fullSemVer }},enable=${{ github.ref == 'refs/heads/develop' }} | |
| type=semver,pattern={{version}},value=${{ steps.gitversion.outputs.semVer }},enable=${{ github.ref == 'refs/heads/master' }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ steps.gitversion.outputs.semVer }},enable=${{ github.ref == 'refs/heads/master' }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| BUILD_VERSION=${{ steps.gitversion.outputs.fullSemVer }} | |
| BUILD_DATE=${{ github.event.repository.updated_at }} | |
| VCS_REF=${{ github.sha }} | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |