fix: Formatting #62
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| jobs: | |
| templ-generate: | |
| name: Templ Generate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Install templ | |
| run: go install github.com/a-h/templ/cmd/templ@latest | |
| - name: Generate templ files | |
| run: templ generate | |
| - name: Check for changes | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Generated files are not up to date. Please run 'templ generate' and commit the changes." | |
| git status --porcelain | |
| exit 1 | |
| fi | |
| format: | |
| name: Format Check | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Run format check | |
| run: docker buildx bake format | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Install templ | |
| run: go install github.com/a-h/templ/cmd/templ@latest | |
| - name: Generate templ files | |
| run: templ generate | |
| - name: Install SQLite headers | |
| run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| version: latest | |
| args: --timeout=5m | |
| env: | |
| CGO_ENABLED: 1 | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Install templ | |
| run: go install github.com/a-h/templ/cmd/templ@latest | |
| - name: Generate templ files | |
| run: templ generate | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Run tests | |
| run: docker buildx bake test | |
| build-dev: | |
| name: Build Development | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate, format, lint, test] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Build development version | |
| run: docker buildx bake build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: msgtausch-dev-binaries | |
| path: bin/ | |
| retention-days: 7 | |
| build-pr: | |
| name: Build Pull Request | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate, format, lint, test] | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Build pull request version | |
| run: docker buildx bake build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: msgtausch-pr-binaries-${{ github.event.number }} | |
| path: bin/ | |
| retention-days: 1 | |
| nix-build: | |
| name: Nix Build | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate, format, lint, test] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Run nix build | |
| run: docker buildx bake nix | |
| - name: Upload nix artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: msgtausch-nix-binaries | |
| path: result/bin/ | |
| retention-days: 7 | |
| simulation: | |
| name: Simulation | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate, format, lint, test] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Run simulation | |
| run: docker buildx bake simulation | |
| docker-release: | |
| name: Docker Release | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate, format, lint, test] | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| environment: default | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} | |
| QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to Quay.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: quay.io | |
| username: ${{ secrets.QUAY_USERNAME }} | |
| password: ${{ secrets.QUAY_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| codefionn/msgtausch | |
| quay.io/codefionn/msgtausch | |
| tags: | | |
| type=ref,event=tag | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| target: runtime-release | |
| build-args: | | |
| VERSION=${{ github.ref_name }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| docker-dev: | |
| name: Docker Development | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate, format, lint, test] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') | |
| environment: default | |
| env: | |
| DOCKERHUB_USERNAME: codefionn | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| QUAY_USERNAME: codefionn | |
| QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to Quay.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: quay.io | |
| username: ${{ secrets.QUAY_USERNAME }} | |
| password: ${{ secrets.QUAY_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| codefionn/msgtausch | |
| quay.io/codefionn/msgtausch | |
| tags: | | |
| type=ref,event=branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| target: runtime-dev | |
| build-args: | | |
| VERSION=dev | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: [templ-generate, format, lint, test, docker-release] | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: network=host | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Build release | |
| env: | |
| BUILD_CONFIGURATION: release | |
| VERSION: ${{ steps.version.outputs.VERSION }} | |
| run: docker buildx bake release | |
| - name: Upload release artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: msgtausch-release-${{ steps.version.outputs.VERSION }} | |
| path: release/ | |
| retention-days: 90 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| with: | |
| files: release/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |