From 67c85f314d25d49d60205b600da5b791ff314332 Mon Sep 17 00:00:00 2001 From: CommunityMaintained <293462701+CommunityMaintained@users.noreply.github.com> Date: Sun, 14 Jun 2026 13:45:17 -0500 Subject: [PATCH] feat: add release-please, change versioning to SemVer --- .../workflows/{lint_and_test.yml => ci.yml} | 13 +- .github/workflows/docker_release.yml | 86 ---------- .github/workflows/release-please.yml | 157 ++++++++++++++++++ .release-please-manifest.json | 3 + release-please-config.json | 7 + version.txt | 1 + 6 files changed, 173 insertions(+), 94 deletions(-) rename .github/workflows/{lint_and_test.yml => ci.yml} (90%) delete mode 100644 .github/workflows/docker_release.yml create mode 100644 .github/workflows/release-please.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json create mode 100644 version.txt diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/ci.yml similarity index 90% rename from .github/workflows/lint_and_test.yml rename to .github/workflows/ci.yml index c174559..889cfb5 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/ci.yml @@ -1,17 +1,14 @@ -name: Perform linting and run tests +name: CI on: push: - branches: - - master + branches-ignore: ["master"] pull_request: - branches: - - master - workflow_dispatch: + branches: ["master"] jobs: - build-and-test: - name: Build, Lint, and Test + test: + name: Lint and Test runs-on: ubuntu-latest if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" env: diff --git a/.github/workflows/docker_release.yml b/.github/workflows/docker_release.yml deleted file mode 100644 index 3dace42..0000000 --- a/.github/workflows/docker_release.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: Docker Release - -on: - workflow_dispatch: - inputs: - platforms: - type: choice - description: 'Build Platforms' - required: true - default: 'linux/amd64' - options: - - 'linux/amd64' - - 'linux/amd64,linux/arm64' - docker_tags: - type: string - description: 'Docker Tags' - required: true - default: 'dev' - - push: - branches: - - master - release: - types: - - published - -jobs: - build_and_push_docker: - runs-on: ubuntu-latest - env: - dev_arch: 'linux/amd64' - release_arch: 'linux/amd64,linux/arm64' - permissions: - contents: read - packages: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - docker.io/communitymaintained/pinchflat - ghcr.io/${{ github.repository }} - # All non-release actions will be tagged as `dev` (ie: push, workflow_dispatch) - tags: | - type=ref,event=tag - type=raw,value=dev,enable=${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }} - type=raw,value=${{ inputs.docker_tags }},enable=${{ github.event_name == 'workflow_dispatch' }} - flavor: | - latest=auto - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and Push - uses: docker/build-push-action@v6 - with: - context: . - file: ./docker/selfhosted.Dockerfile - # If the event is a release, use the release_arch, otherwise use the - # platforms input if present, falling back to dev_arch - platforms: ${{ github.event_name == 'release' && env.release_arch || (github.event.inputs.platforms || env.dev_arch) }} - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..4ddc748 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,157 @@ +name: Release Please + +on: + push: + branches: ["master"] + +jobs: + test: + name: Lint and Test + runs-on: ubuntu-latest + env: + COMPOSE_FILE: ./docker-compose.ci.yml + MIX_ENV: test + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Pull prebuilt images + run: docker compose pull + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/dev.Dockerfile + load: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Run Docker image + run: docker compose up --detach + + - name: Install Elixir and JS deps + run: | + docker compose exec -T phx mix deps.get && yarn install && cd assets && yarn install && cd .. + + - name: Create and Migrate database + run: | + docker compose exec -T phx mix ecto.create + docker compose exec -T phx mix ecto.migrate + + - name: Run code checks + run: docker compose exec -T phx mix check --no-fix --no-retry + + release-please: + name: Release Please + runs-on: ubuntu-latest + needs: test + permissions: + contents: write + pull-requests: write + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - uses: googleapis/release-please-action@v4 + id: release + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + # After a release is published: update mix.exs to CalVer so the running app + # reports the date-based version while GitHub releases/tags stay semver. + update-mix-version: + name: Update mix.exs to CalVer + runs-on: ubuntu-latest + needs: release-please + if: needs.release-please.outputs.release_created == 'true' + permissions: + contents: write + steps: + - name: Checkout master + uses: actions/checkout@v4 + with: + ref: master + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Bump mix.exs version to today's CalVer + run: | + DATE=$(date +"%Y.%-m.%-d") + CURRENT=$(grep 'version: ' mix.exs | cut -d '"' -f2) + sed -i "s/version: \"$CURRENT\"/version: \"$DATE\"/" mix.exs + + - name: Commit and push + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add mix.exs + git diff --cached --quiet || git commit -m "chore: update app version to $(date +"%Y.%-m.%-d") [skip ci]" + git push + + docker: + name: Build and Push Docker Image + runs-on: ubuntu-latest + needs: [test, release-please] + permissions: + contents: read + packages: write + env: + dev_arch: 'linux/amd64' + release_arch: 'linux/amd64,linux/arm64' + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Strip v prefix from release tag + id: version + if: needs.release-please.outputs.release_created == 'true' + run: | + echo "value=$(echo '${{ needs.release-please.outputs.tag_name }}' | sed 's/^v//')" >> $GITHUB_OUTPUT + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + docker.io/communitymaintained/pinchflat + ghcr.io/${{ github.repository }} + tags: | + type=raw,value=${{ steps.version.outputs.value }},enable=${{ needs.release-please.outputs.release_created == 'true' }} + type=raw,value=latest,enable=${{ needs.release-please.outputs.release_created == 'true' }} + type=raw,value=dev,enable=${{ needs.release-please.outputs.release_created != 'true' }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/selfhosted.Dockerfile + platforms: ${{ needs.release-please.outputs.release_created == 'true' && env.release_arch || env.dev_arch }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..e0389a4 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.9.9" +} diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..1dee2e9 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "simple", + "packages": { + ".": {} + } +} diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..7e310ba --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.9.9