From ee763df5c345df90de39e4484be87e10a534e582 Mon Sep 17 00:00:00 2001 From: trueberryless Date: Sun, 2 Mar 2025 19:29:10 +0100 Subject: [PATCH 1/2] add dotnet support and rig --- .changeset/polite-pumpkins-pay.md | 5 + repos.json | 155 ++++++++++++++++ template-files/.changeset/Dotnet.config.json | 18 ++ .../.github/workflows/deployment-dotnet.yaml | 170 ++++++++++++++++++ template-files/.gitignore/DotNet.gitignore | 37 ++++ template-files/Dockerfile/DotNet.Dockerfile | 23 +++ 6 files changed, 408 insertions(+) create mode 100644 .changeset/polite-pumpkins-pay.md create mode 100644 template-files/.changeset/Dotnet.config.json create mode 100644 template-files/.github/workflows/deployment-dotnet.yaml create mode 100644 template-files/.gitignore/DotNet.gitignore create mode 100644 template-files/Dockerfile/DotNet.Dockerfile diff --git a/.changeset/polite-pumpkins-pay.md b/.changeset/polite-pumpkins-pay.md new file mode 100644 index 0000000..48313c7 --- /dev/null +++ b/.changeset/polite-pumpkins-pay.md @@ -0,0 +1,5 @@ +--- +"template-files": patch +--- + +Add DotNet Support: Release Image Generator diff --git a/repos.json b/repos.json index a09a37b..bea6e1a 100644 --- a/repos.json +++ b/repos.json @@ -2866,6 +2866,161 @@ "special": "package.json" } ] + }, + { + "name": "trueberryless-org/release-image-generator", + "files": [ + { + "path": "template-files/.changeset/DotNet.config.json", + "targetPath": ".changeset/config.json", + "props": { + "repositoryName": "release-image-generator" + } + }, + { + "path": "template-files/.changeset/README.md", + "targetPath": ".changeset/README.md", + "props": { + "repositoryName": "release-image-generator" + } + }, + { + "path": "template-files/.dockerignore", + "targetPath": "app/.dockerignore" + }, + { + "path": "template-files/.github/labeler.yaml", + "targetPath": ".github/labeler.yaml" + }, + { + "path": "template-files/.github/workflows/deployment-dotnet.yaml", + "targetPath": ".github/workflows/deployment.yaml", + "props": { + "branchName": "main", + "repositoryName": "release-image-generator", + "projectFolder": "app", + "makeLatest": "true" + } + }, + { + "path": "template-files/.github/workflows/format.yaml", + "targetPath": ".github/workflows/format.yaml", + "props": { + "branchName": "main" + } + }, + { + "path": "template-files/.github/workflows/labeler.yaml", + "targetPath": ".github/workflows/labeler.yaml" + }, + { + "path": "template-files/.github/workflows/release.yaml", + "targetPath": ".github/workflows/release.yaml", + "props": { + "branchName": "main" + } + }, + { + "path": "template-files/.github/workflows/welcome-bot.yaml", + "targetPath": ".github/workflows/welcome-bot.yaml", + "props": { + "branchName": "main" + } + }, + { + "path": "template-files/.gitignore/DotNet.gitignore", + "targetPath": ".gitignore" + }, + { + "path": "template-files/Dockerfile/DotNet.Dockerfile", + "targetPath": "Dockerfile", + "props": { + "projectFolder": "ReleaseImageGenerator", + "projectName": "ReleaseImageGenerator.API" + } + }, + { + "path": "template-files/package.json/package.manager.package.json", + "targetPath": "app/package.json", + "special": "package.json" + }, + { + "path": "template-files/LICENSE", + "targetPath": "LICENSE", + "props": { + "year": "2025" + } + }, + { + "path": "template-files/manifest/certificate.yaml", + "targetPath": "manifest/certificate.yaml", + "props": { + "repositoryName": "release-image-generator", + "subdomainName": "release-image-generator" + } + }, + { + "path": "template-files/manifest/deployment.yaml", + "targetPath": "manifest/deployment.yaml", + "special": "manifest/deployment.yaml", + "props": { + "repositoryName": "release-image-generator" + } + }, + { + "path": "template-files/manifest/ingress.yaml", + "targetPath": "manifest/ingress.yaml", + "props": { + "repositoryName": "release-image-generator", + "subdomainName": "release-image-generator" + } + }, + { + "path": "template-files/manifest/namespace.yaml", + "targetPath": "manifest/namespace.yaml", + "props": { + "repositoryName": "release-image-generator" + } + }, + { + "path": "template-files/manifest/service.yaml", + "targetPath": "manifest/service.yaml", + "props": { + "repositoryName": "release-image-generator" + } + }, + { + "path": "template-files/package.json/changeset.package.json", + "targetPath": "package.json", + "special": "package.json" + }, + { + "path": "template-files/package.json/package.manager.package.json", + "targetPath": "package.json", + "special": "package.json" + }, + { + "path": "template-files/package.json/definition.package.json", + "targetPath": "package.json", + "special": "package.json", + "props": { + "packageName": "release-image-generator-monorepo", + "repositoryName": "release-image-generator" + } + }, + { + "path": "template-files/README.md", + "targetPath": "packages/release-image-generator/README.md", + "special": "README.md" + }, + { + "path": "template-files/pnpm-workspace.yaml", + "targetPath": "pnpm-workspace.yaml", + "props": { + "documentationFolder": "app" + } + } + ] } ] } diff --git a/template-files/.changeset/Dotnet.config.json b/template-files/.changeset/Dotnet.config.json new file mode 100644 index 0000000..68286b8 --- /dev/null +++ b/template-files/.changeset/Dotnet.config.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json", + "changelog": [ + "@changesets/changelog-github", + { "repo": "trueberryless-org/<%= repositoryName %>" } + ], + "commit": false, + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [], + "privatePackages": { + "version": true, + "tag": true + } +} diff --git a/template-files/.github/workflows/deployment-dotnet.yaml b/template-files/.github/workflows/deployment-dotnet.yaml new file mode 100644 index 0000000..27e3e91 --- /dev/null +++ b/template-files/.github/workflows/deployment-dotnet.yaml @@ -0,0 +1,170 @@ +name: Deployment + +on: + push: + branches: [<%= branchName %>] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} + cancel-in-progress: true + +env: + REGISTRY: docker.io + IMAGE_OWNER: trueberryless + IMAGE_NAME: <%= repositoryName %> + NODE_VERSION: 20 + +jobs: + changesets: + name: Changesets + runs-on: ubuntu-latest + outputs: + hasChangesets: ${{ steps.changesets.outputs.hasChangesets }} + permissions: + contents: write + pull-requests: write + steps: + - name: Generate GitHub App token + id: generate_token + uses: tibdex/github-app-token@v2.1.0 + with: + app_id: ${{ secrets.BOT_APP_ID }} + private_key: ${{ secrets.BOT_PRIVATE_KEY }} + + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Setup PNPM + uses: pnpm/action-setup@v3 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "pnpm" + + - name: Install Dependencies + run: pnpm i + + - name: Create Release Pull Request + id: changesets + uses: changesets/action@v1 + with: + commit: "[ci] release" + title: "[ci] release" + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + image-tag: + name: Image Tag + runs-on: ubuntu-latest + outputs: + IMAGE_TAG: ${{ env.IMAGE_TAG }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Read version from package.json + id: get_version + run: | + VERSION=$(jq -r '.version' <%= projectFolder %>/package.json) + echo "IMAGE_TAG=$VERSION" >> $GITHUB_ENV + + deployment: + needs: [changesets, image-tag] + if: > + ( + needs.changesets.outputs.hasChangesets == 'false' && + ( + contains(github.event.head_commit.message, 'deploy') || + contains(github.event.head_commit.message, '[ci] release') + ) + ) || + github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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 metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: ./<%= projectFolder %> + push: true + tags: | + ${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ needs.image-tag.outputs.IMAGE_TAG }} + ${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} + + - name: Update deployment.yaml file + run: | + yq eval '.spec.template.spec.containers[0].image = "${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ needs.image-tag.outputs.IMAGE_TAG }}"' -i manifest/deployment.yaml + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: update deployment.json container image (automated) + + release: + name: Release + needs: [image-tag, deployment] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - id: extract-changelog + uses: sean0x42/markdown-extract@v2.1.0 + with: + file: <%= projectFolder %>/CHANGELOG.md + pattern: ${{ needs.image-tag.outputs.IMAGE_TAG }} + + - uses: ncipollo/release-action@v1 + id: create_release + with: + tag: ${{ env.IMAGE_NAME }}@${{ needs.image-tag.outputs.IMAGE_TAG }} + makeLatest: <%= makeLatest %> + body: ${{ steps.extract-changelog.outputs.markdown }} + skipIfReleaseExists: true + + - name: Check if release was created + id: check_release + run: | + if [ -z "${{ steps.create_release.outputs.html_url }}" ]; then + echo "RELEASE_SKIPPED=true" >> $GITHUB_ENV + else + echo "RELEASE_SKIPPED=false" >> $GITHUB_ENV + fi + + - name: Discord notification + if: env.RELEASE_SKIPPED == 'false' + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} + uses: Ilshidur/action-discord@0.3.2 + with: + args: | + # ${{ env.IMAGE_NAME }}@${{ needs.image-tag.outputs.IMAGE_TAG }} + + ${{ steps.extract-changelog.outputs.markdown }} diff --git a/template-files/.gitignore/DotNet.gitignore b/template-files/.gitignore/DotNet.gitignore new file mode 100644 index 0000000..a437a65 --- /dev/null +++ b/template-files/.gitignore/DotNet.gitignore @@ -0,0 +1,37 @@ +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode + +# Rider +.idea + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio 2015 +.vs/ diff --git a/template-files/Dockerfile/DotNet.Dockerfile b/template-files/Dockerfile/DotNet.Dockerfile new file mode 100644 index 0000000..35dbb29 --- /dev/null +++ b/template-files/Dockerfile/DotNet.Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["<%= projectFolder %>/<%= projectName %>.csproj", "<%= projectFolder %>/"] +RUN dotnet restore "<%= projectFolder %>/<%= projectName %>.csproj" +COPY . . +WORKDIR "/src/<%= projectFolder %>" +RUN dotnet build "<%= projectName %>.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "<%= projectName %>.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "<%= projectName %>.dll"] From 2337f510986e3ffef44dec006483d8a5240396b8 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 2 Mar 2025 18:30:21 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- repos.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/repos.json b/repos.json index bea6e1a..50c7777 100644 --- a/repos.json +++ b/repos.json @@ -2884,10 +2884,6 @@ "repositoryName": "release-image-generator" } }, - { - "path": "template-files/.dockerignore", - "targetPath": "app/.dockerignore" - }, { "path": "template-files/.github/labeler.yaml", "targetPath": ".github/labeler.yaml" @@ -2931,6 +2927,15 @@ "path": "template-files/.gitignore/DotNet.gitignore", "targetPath": ".gitignore" }, + { + "path": "template-files/.dockerignore", + "targetPath": "app/.dockerignore" + }, + { + "path": "template-files/package.json/package.manager.package.json", + "targetPath": "app/package.json", + "special": "package.json" + }, { "path": "template-files/Dockerfile/DotNet.Dockerfile", "targetPath": "Dockerfile", @@ -2939,11 +2944,6 @@ "projectName": "ReleaseImageGenerator.API" } }, - { - "path": "template-files/package.json/package.manager.package.json", - "targetPath": "app/package.json", - "special": "package.json" - }, { "path": "template-files/LICENSE", "targetPath": "LICENSE",