From baa4a667df35f77703383ee8d0828e7a478b176f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 22 Apr 2024 14:00:47 +0200 Subject: [PATCH 1/2] ci: add changelog check --- .github/workflows/changelog.yml | 39 +++++++++++++++++++++++++++++++++ CHANGELOG.md | 24 ++++++++++++++++++++ README.md | 6 ++++- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/changelog.yml create mode 100644 CHANGELOG.md diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..59b04c1 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,39 @@ +name: Changelog + +on: + pull_request: + types: + - opened + - edited + - synchronize + - reopened + - labeled + - unlabeled + paths: + - '**.go' + - '**/go.mod' + - '**/go.sum' + +jobs: + changelog: + if: contains(github.event.pull_request.title, '[skip changelog]') == false && + contains(github.event.pull_request.labels.*.name, 'skip/changelog') == false + runs-on: ubuntu-latest + name: Changelog + steps: + - id: changelog + env: + GITHUB_TOKEN: ${{ github.token }} + ENDPOINT: repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files + SELECTOR: 'map(select(.filename == "CHANGELOG.md")) | length' + run: gh api "$ENDPOINT" --jq "$SELECTOR" | xargs -I{} echo "modified={}" | tee -a $GITHUB_OUTPUT + - if: steps.changelog.outputs.modified == '0' + env: + MESSAGE: | + CHANGELOG.md was not modified in this PR. Please do one of the following: + - add a changelog entry + - add `[skip changelog]` to the PR title + - label the PR with `skip/changelog` + run: | + echo "::error::${MESSAGE//$'\n'/%0A}" + exit 1 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a6540b4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +Note: +* The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +* This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Legend +The following emojis are used to highlight certain changes: +* 🛠 - BREAKING CHANGE. Action is required if you use this functionality. +* ✨ - Noteworthy change to be aware of. + +## [Unreleased] + +### Added + +### Changed + +### Removed + +### Fixed + +### Security diff --git a/README.md b/README.md index 8e2c616..9b23ee2 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,11 @@ Suggested method for self-hosting is to run a [prebuilt Docker image](#docker). ## Release -To make a release, create a new PR that updates the [`version.json`](./version.json) file. This PR should not include any other changes besides the version bump. A new release will be automatically made once the PR is merged +1. Create a PR from branch `release-vX.Y.Z` against `main` that: + 1. Tidies the [`CHANGELOG.md`](CHANGELOG.md) with the changes for the current release + 2. Updates the [`version.json`](./version.json) file +2. Once the release checker creates a draft release, copy-paste the changelog into the draft +3. Merge the PR, the release will be automatically created once the PR is merged ## License From 090fb878e947c31bcc23949d018833063f7711af Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 22 Apr 2024 14:02:21 +0200 Subject: [PATCH 2/2] ci: trigger docker on release --- .github/workflows/docker.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 415fa30..35d1af7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,16 +1,42 @@ name: Create and publish a Docker image on: + workflow_dispatch: push: branches: ['main', 'staging'] tags: ['v*'] + workflow_run: + workflows: [Releaser] + types: + - completed env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: + prepare_checkout: + if: ( + github.repository == 'ipfs/someguy' + || github.event_name == 'workflow_dispatch' + ) && ( + github.event_name != 'workflow_run' + || github.event.workflow_run.conclusion == 'success' + ) + name: Decide what ref to check out + runs-on: ubuntu-latest + outputs: + ref: ${{ github.event_name != 'workflow_run' && github.ref || steps.releaser.outputs.version }} + steps: + - name: Inspect triggering Releaser workflow run + id: releaser + if: github.event_name == 'workflow_run' + uses: ipdxco/unified-github-workflows/.github/actions/inspect-releaser@v1.0 + with: + artifacts-url: ${{ github.event.workflow_run.artifacts_url }} build-and-push-image: + needs: [prepare_checkout] + if: needs.prepare_checkout.outputs.ref != '' runs-on: ubuntu-latest permissions: contents: read @@ -18,6 +44,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare_checkout.outputs.ref }} + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -43,7 +72,7 @@ jobs: IMAGE_NAME: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} run: | echo "value<> $GITHUB_OUTPUT - ./.github/scripts/get-docker-tags.sh "$(date -u +%F)" >> $GITHUB_OUTPUT + ./docker/get-docker-tags.sh "$(date -u +%F)" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT shell: bash - name: Build Docker image and publish to Docker Hub