From e7a678e91f3f4db0fe2b3b2e09d1026b1a8f3c3c Mon Sep 17 00:00:00 2001 From: Jonas L Date: Fri, 22 Dec 2023 19:19:12 +0100 Subject: [PATCH] build: replace custom release script with release-please (#2817) * build: replace custom release script with release-please * include package-name --- .chglog/CHANGELOG.md.tpl | 22 ------- .chglog/config.yml | 25 -------- .github/release-please-config.json | 20 +++++++ .github/release-please-manifest.json | 1 + .github/workflows/backport.yml | 27 +++++++++ .github/workflows/release-please.yml | 20 +++++++ .github/workflows/release.yml | 5 +- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 22 +------ Makefile | 3 - analyzer/setup.py | 4 +- api-client/setup.py | 4 +- api/setup.py | 4 +- docs/contributor-manual/releases.md | 88 ++++------------------------ playout/setup.py | 4 +- shared/setup.py | 4 +- tools/bump-python-version.sh | 21 ------- tools/changelog.sh | 25 -------- worker/setup.py | 4 +- 19 files changed, 102 insertions(+), 203 deletions(-) delete mode 100644 .chglog/CHANGELOG.md.tpl delete mode 100644 .chglog/config.yml create mode 100644 .github/release-please-config.json create mode 100644 .github/release-please-manifest.json create mode 100644 .github/workflows/backport.yml create mode 100644 .github/workflows/release-please.yml delete mode 100755 tools/bump-python-version.sh delete mode 100755 tools/changelog.sh diff --git a/.chglog/CHANGELOG.md.tpl b/.chglog/CHANGELOG.md.tpl deleted file mode 100644 index 296e50974..000000000 --- a/.chglog/CHANGELOG.md.tpl +++ /dev/null @@ -1,22 +0,0 @@ -{{ range .Versions }} - -## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }}) - -- [Release note](https://libretime.org/docs/releases/{{ .Tag.Name }}/) - -{{ range .CommitGroups -}} -### {{ .Title }} - -{{ range reverse .Commits -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{ end }} -{{ end -}} - -{{- if .RevertCommits -}} -### Reverts - -{{ range .RevertCommits -}} -- {{ .Revert.Header }} -{{ end }} -{{ end -}} -{{ end -}} diff --git a/.chglog/config.yml b/.chglog/config.yml deleted file mode 100644 index 262f1e232..000000000 --- a/.chglog/config.yml +++ /dev/null @@ -1,25 +0,0 @@ -style: github -template: CHANGELOG.md.tpl -info: - title: CHANGELOG - repository_url: https://github.com/libretime/libretime -options: - commits: - filters: - Type: [feat, fix, docs, test, ci] - sort_by: Date - commit_groups: - title_maps: - feat: Features - fix: Bug Fixes - docs: Documentation - test: Tests - ci: CI - sort_by: Custom - title_order: [feat, fix, docs, test, ci] - header: - pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" - pattern_maps: - - Type - - Scope - - Subject diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 000000000..fae2d122b --- /dev/null +++ b/.github/release-please-config.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "bootstrap-sha": "26737abad231d96fc198fbf12c043f2d867be79c", + "include-component-in-tag": false, + "include-v-in-tag": false, + "packages": { + ".": { + "release-type": "simple", + "package-name": "libretime", + "extra-files": [ + "analyzer/setup.py", + "api/setup.py", + "api-client/setup.py", + "playout/setup.py", + "shared/setup.py", + "worker/setup.py" + ] + } + } +} diff --git a/.github/release-please-manifest.json b/.github/release-please-manifest.json new file mode 100644 index 000000000..3062c8f97 --- /dev/null +++ b/.github/release-please-manifest.json @@ -0,0 +1 @@ +{".":"3.2.0"} diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 000000000..3f97bfb3e --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,27 @@ +name: Backport + +on: + pull_request_target: + types: + - closed + - labeled + +jobs: + backport: + runs-on: ubuntu-latest + + # Only react to merged PRs for security reasons. + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target. + if: > + github.event.pull_request.merged + && ( + github.event.action == 'closed' + || ( + github.event.action == 'labeled' + && contains(github.event.label.name, 'backport') + ) + ) + steps: + - uses: tibdex/backport@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 000000000..55150689e --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,20 @@ +name: Release-Please + +on: + push: + branches: + - main + - stable + +jobs: + release-please: + # Do not run on forks. + if: github.repository == 'libretime/libretime' + + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v4 + with: + config-file: .github/release-please-config.json + manifest-file: .github/release-please-manifest.json + target-branch: ${{ github.ref_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8dfe3b9aa..92d91c4b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,12 +22,9 @@ jobs: - name: Build tarball run: make tarball - - name: Create Release + - name: Upload tarball uses: softprops/action-gh-release@v1 with: - body_path: docs/releases/${{ github.ref_name }}.md - draft: true - prerelease: true files: | libretime-*.tar.gz sha256sums.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index abde06f12..ec03bfad5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: hooks: - id: prettier files: \.(md|mdx|yml|yaml|js|jsx|ts|tsx|json|css)$ - exclude: ^legacy/public(?!/js/airtime) + exclude: ^(legacy/public(?!/js/airtime)|CHANGELOG.md$|.github/release-please-manifest.json) - repo: https://github.com/asottile/pyupgrade rev: v3.15.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 896739557..4834f5d24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ - +# Changelog ## [3.2.0](https://github.com/libretime/libretime/compare/3.1.0...3.2.0) (2023-10-16) @@ -38,8 +38,6 @@ - **playout:** check unsupported liquidsoap aac output - - ## [3.1.0](https://github.com/libretime/libretime/compare/3.0.2...3.1.0) (2023-05-26) - [Release note](https://libretime.org/docs/releases/3.1.0/) @@ -230,8 +228,6 @@ - chore(api): install django-rest-framework from git ([#2518](https://github.com/libretime/libretime/issues/2518)) - - ## [3.0.2](https://github.com/libretime/libretime/compare/3.0.1...3.0.2) (2023-02-21) - [Release note](https://libretime.org/docs/releases/3.0.2/) @@ -263,8 +259,6 @@ - don't squash commits during docs sync - test project weekly - - ## [3.0.1](https://github.com/libretime/libretime/compare/3.0.0...3.0.1) (2022-12-20) - [Release note](https://libretime.org/docs/releases/3.0.1/) @@ -293,8 +287,6 @@ - sync docs with libretime/website repository - pin vale version to v2.21.3 - - ## [3.0.0](https://github.com/libretime/libretime/compare/3.0.0-beta.2...3.0.0) (2022-10-10) - [Release note](https://libretime.org/docs/releases/3.0.0/) @@ -315,8 +307,6 @@ - **analyzer:** fix wrong bit_rate values - - ## [3.0.0-beta.2](https://github.com/libretime/libretime/compare/3.0.0-beta.1...3.0.0-beta.2) (2022-10-03) - [Release note](https://libretime.org/docs/releases/3.0.0-beta.2/) @@ -345,8 +335,6 @@ - allow failure when linting /docs/releases - use github.ref_name to get tag - - ## [3.0.0-beta.1](https://github.com/libretime/libretime/compare/3.0.0-beta.0...3.0.0-beta.1) (2022-09-23) - [Release note](https://libretime.org/docs/releases/3.0.0-beta.1/) @@ -379,8 +367,6 @@ - don't check github.com/libretime/libretime/(issues|pulls) links - run docs workflow on vale files changes - - ## [3.0.0-beta.0](https://github.com/libretime/libretime/compare/3.0.0-alpha.13...3.0.0-beta.0) (2022-09-16) - [Release note](https://libretime.org/docs/releases/3.0.0-beta.0/) @@ -530,8 +516,6 @@ - improve containers build caching - add container tags - - ## [3.0.0-alpha.13](https://github.com/libretime/libretime/compare/3.0.0-alpha.12...3.0.0-alpha.13) (2022-07-15) - [Release note](https://libretime.org/docs/releases/3.0.0-alpha.13/) @@ -692,8 +676,6 @@ - disable codecov project status check - disable codecov patch status check - - ## [3.0.0-alpha.12](https://github.com/libretime/libretime/compare/3.0.0-alpha.11...3.0.0-alpha.12) (2022-03-29) - [Release note](https://libretime.org/docs/releases/3.0.0-alpha.12/) @@ -708,8 +690,6 @@ - add missing data to release note - fix and update links ([#1714](https://github.com/libretime/libretime/issues/1714)) - - ## [3.0.0-alpha.11](https://github.com/libretime/libretime/compare/3.0.0-alpha.10...3.0.0-alpha.11) (2022-03-28) - [Release note](https://libretime.org/docs/releases/3.0.0-alpha.11/) diff --git a/Makefile b/Makefile index a237714f6..c06367a7c 100644 --- a/Makefile +++ b/Makefile @@ -31,9 +31,6 @@ dev: .env dev-certs VERSION: tools/version.sh -changelog: - tools/changelog.sh - .PHONY: tarball tarball: VERSION $(MAKE) -C legacy build diff --git a/analyzer/setup.py b/analyzer/setup.py index 7373626d3..f57cb3c57 100644 --- a/analyzer/setup.py +++ b/analyzer/setup.py @@ -1,8 +1,10 @@ from setuptools import find_packages, setup +version = "3.2.0" # x-release-please-version + setup( name="libretime-analyzer", - version="3.2.0", + version=version, description="Libretime Analyzer", author="LibreTime Contributors", url="https://github.com/libretime/libretime", diff --git a/api-client/setup.py b/api-client/setup.py index 32099855c..6f350d468 100644 --- a/api-client/setup.py +++ b/api-client/setup.py @@ -1,8 +1,10 @@ from setuptools import find_packages, setup +version = "3.2.0" # x-release-please-version + setup( name="libretime-api-client", - version="3.2.0", + version=version, description="LibreTime API Client", author="LibreTime Contributors", url="https://github.com/libretime/libretime", diff --git a/api/setup.py b/api/setup.py index 7a40ac238..a549786f7 100644 --- a/api/setup.py +++ b/api/setup.py @@ -1,8 +1,10 @@ from setuptools import find_packages, setup +version = "3.2.0" # x-release-please-version + setup( name="libretime-api", - version="3.2.0", + version=version, description="LibreTime API", author="LibreTime Contributors", url="https://github.com/libretime/libretime", diff --git a/docs/contributor-manual/releases.md b/docs/contributor-manual/releases.md index 4ff6b70c8..43c6dbbe4 100644 --- a/docs/contributor-manual/releases.md +++ b/docs/contributor-manual/releases.md @@ -6,47 +6,17 @@ title: Releases This guide walks you through the steps required to release a new version of LibreTime. -:::caution +### 1. Inspect the release pull request -This guide is still a work in progress, and doesn't cover every use cases. Depending on -the version bump, some steps might be wrong. For example, in case of a patch release, -the documentation requires different changes. +A release pull request is maintained by [`release-please`](https://github.com/googleapis/release-please). `release-please` guesses the next version to release based on the commit history, and will generate a changelog for that release. -::: - -Before releasing a new version, make sure linter don't fail and tests are passing. - -Start by cleaning the repository and make sure you don't have uncommitted changes: - -``` -git checkout main -make clean -git status -``` - -Choose the next version based the our [versioning schema](#versioning-schema): +Once a release is desired, checkout the release branch: ```bash -export VERSION=3.0.0-beta.0 -``` - -Create a new `release-$VERSION` branch and release commit to prepare a release pull request: - -```bash -git checkout -b "release-$VERSION" -export COMMIT_MESSAGE="chore: release $VERSION" -git commit --allow-empty --message="$COMMIT_MESSAGE" -``` - -### 1. Version bump - -Write the new `$VERSION` to the VERSION file, and bump the python packages version: - -```bash -bash tools/bump-python-version.sh "$VERSION" - -git add . -git commit --fixup ":/$COMMIT_MESSAGE" +# For a release on the main branch +git checkout release-please--branches--main--components--libretime +# For a release on the stable branch +git checkout release-please--branches--stable--components--libretime ``` ### 2. Release note @@ -72,48 +42,16 @@ Reset and clean the `docs/releases/unreleased.md` file for a future version. Commit the release note changes: ```bash -git add . -git commit --fixup ":/$COMMIT_MESSAGE" +git add docs/releases +git commit -m "docs: add release note" ``` -### 3. Create a new pull request +### 4. Merge the release pull request -Squash the changes and open a pull request for others to review: +Push any changes that we previously made to the release branch: ```bash -git rebase --autosquash --interactive main +git push ``` -Merge the pull request when it's reviewed and ready. - -### 4. Create and push a tag - -Pull the merged release commit: - -```bash -git checkout main -git pull upstream main -``` - -Make sure `HEAD` is the previously merged release commit and tag it with the new version: - -```bash -git show --quiet - -git tag -a -m "$VERSION" "$VERSION" -``` - -Generate the changelog for the newly tagged version: - -```bash -make changelog - -git add . -git commit -m "chore: generate changelog for $VERSION" -``` - -Push the tag upstream to finalize the release process: - -```bash -git push upstream main --follow-tags -``` +Once the pull request CI succeeded and everything is ready, merge the release pull request. `release-please` will create a tag and a release, which will trigger the final release pipeline that will upload the tarball as release assets. diff --git a/playout/setup.py b/playout/setup.py index c8a90aa28..d9dde3359 100644 --- a/playout/setup.py +++ b/playout/setup.py @@ -1,8 +1,10 @@ from setuptools import find_packages, setup +version = "3.2.0" # x-release-please-version + setup( name="libretime-playout", - version="3.2.0", + version=version, description="LibreTime Playout", author="LibreTime Contributors", url="https://github.com/libretime/libretime", diff --git a/shared/setup.py b/shared/setup.py index e16f0e733..d777700b4 100644 --- a/shared/setup.py +++ b/shared/setup.py @@ -1,8 +1,10 @@ from setuptools import find_packages, setup +version = "3.2.0" # x-release-please-version + setup( name="libretime-shared", - version="3.2.0", + version=version, description="LibreTime Shared", url="https://github.com/libretime/libretime", author="LibreTime Contributors", diff --git a/tools/bump-python-version.sh b/tools/bump-python-version.sh deleted file mode 100755 index c4fe3bed1..000000000 --- a/tools/bump-python-version.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# Bump the version in the setup.py files. - -set -u - -error() { - echo >&2 "error: $*" - exit 1 -} - -command -v sed > /dev/null || error "sed command not found!" - -version="$1" - -for setup_path in */setup.py; do - sed --in-place \ - "s/version=\".*\",/version=\"$version\",/" \ - "$setup_path" || - error "could not bump version for $setup_path!" -done diff --git a/tools/changelog.sh b/tools/changelog.sh deleted file mode 100755 index 685b9e4cd..000000000 --- a/tools/changelog.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -set -u - -error() { - echo >&2 "error: $*" - exit 1 -} - -command -v git > /dev/null || error "git command not found!" -command -v git-chglog > /dev/null || error "git-chglog command not found!" - -changelog="CHANGELOG.md" -tag="${tag:-$(git describe --abbrev=0 --tags || error "could not extract latest tag")}" - -if grep --quiet "" "$changelog"; then - error "changelog has already been generated for tag $tag!" -fi - -cat <(git-chglog "$tag") "$changelog" > "$changelog.tmp" -mv "$changelog.tmp" "$changelog" - -if command -v npx > /dev/null; then - npx prettier --write "$changelog" -fi diff --git a/worker/setup.py b/worker/setup.py index 4d0bbdfc6..7ee8f750c 100644 --- a/worker/setup.py +++ b/worker/setup.py @@ -1,8 +1,10 @@ from setuptools import find_packages, setup +version = "3.2.0" # x-release-please-version + setup( name="libretime-worker", - version="3.2.0", + version=version, description="LibreTime Worker", author="LibreTime Contributors", url="https://github.com/libretime/libretime",