Skip to content

Commit

Permalink
Add changelog gatherer; introduce the new versioning system (#139)
Browse files Browse the repository at this point in the history
* Changelog gatherer

* DataLens release v1.2.0

* update docker-compose.yml docker-compose-dev.yml

* DataLens release v1.3.0

* update docker-compose.yml docker-compose-dev.yml

* Release DataLens v1.4.0 (#11)

* DataLens release v1.4.0

* Update CHANGELOG.md

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: KonstantAnxiety <[email protected]>

* Fix workflow

* Refactor changelog gatherer

* Fix workflow

* Fix workflow

* Fix workflow

* Fix workflow

* Release DataLens v1.5.0 (#13)

* DataLens release v1.5.0

* Update CHANGELOG.md

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: KonstantAnxiety <[email protected]>

* Remove debug

* DataLens release v1.6.0 (#14)

Co-authored-by: github-actions <[email protected]>

* Sync for pr

* Sync for pr 2

* Add changelog gatherer readme

* Remove personal repo

* Add more components

* More info about labels in README

* Sync versions

* Sync changelog date

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: GitHub Actions <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored May 31, 2024
1 parent ddeb6ff commit e920dbd
Show file tree
Hide file tree
Showing 13 changed files with 985 additions and 4 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Update release

on:
pull_request:
branches:
- 'main'
paths:
- 'CHANGELOG.md'

permissions:
contents: write

jobs:
run_if:
if: startsWith(github.head_ref, 'release/')
name: "Sync changelog"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: "${{ github.event.inputs.branch }}"
fetch-depth: 0

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install python dependencies
working-directory: .github/workflows/scripts/changelog
run: pip install -r requirements.txt

- name: Update release from changelog
working-directory: .github/workflows/scripts/changelog
env:
GH_TOKEN: ${{ github.token }}
run: |
python update_release.py \
--changelog-path="../../../../CHANGELOG.md" \
--root-repo-name=${{ github.repository_owner }}/${{ github.event.repository.name }}
142 changes: 142 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Create release

on:
workflow_dispatch:
inputs:
dl_back_version:
type: string
description: "datalens-backend version"
dl_ui_version:
type: string
description: "datalens-ui version"
dl_us_version:
type: string
description: "datalens-us version"
release_type:
type: choice
description: "Release type"
options:
- "major"
- "minor"
- "patch"
default: "minor"

permissions:
contents: write
pull-requests: write

jobs:
run:
name: "Create release"
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.create_branch.outputs.branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: "${{ github.event.inputs.branch }}"
fetch-depth: 0

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install python dependencies
working-directory: .github/workflows/scripts/changelog
run: pip install -r requirements.txt

- name: Render versions input
id: render_versions_input
run: |
dl_back_version=${{ github.event.inputs.dl_back_version }}
dl_ui_version=${{ github.event.inputs.dl_ui_version }}
dl_us_version=${{ github.event.inputs.dl_us_version }}
result=""
if [[ -n "${dl_back_version}" ]]; then
result="datalens-backend:${dl_back_version}"
fi
if [[ -n "${dl_ui_version}" ]]; then
result="$result datalens-ui:${dl_ui_version}"
fi
if [[ -n "${dl_us_version}" ]]; then
result="$result datalens-us:${dl_us_version}"
fi
echo "versions_input=${result}" | tee -a $GITHUB_OUTPUT
- name: Setup user
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Clone repos
working-directory: .github/workflows/scripts/changelog
run: |
CONFIG_FILE="./changelog_config.json" bash clone_repos.sh
- name: Run changelog gatherer
id: gather_changelog
working-directory: .github/workflows/scripts/changelog
env:
GH_TOKEN: ${{ github.token }}
run: |
python releaser.py \
--config-path="./changelog_config.json" \
--repos-dir="./repos" \
--release-type="${{ github.event.inputs.release_type }}" \
--changelog-path="../../../../CHANGELOG.md" \
--version-config-path "../../../../versions-config.json" \
--root-repo-name=${{ github.repository_owner }}/${{ github.event.repository.name }} \
--new-repo-versions "${{ steps.render_versions_input.outputs.versions_input }}" \
--make-outputs \
--create-release
cat outputs.txt | tee -a "$GITHUB_OUTPUT"
- name: Create branch
id: create_branch
run: |
branch="release/${{ steps.gather_changelog.outputs.release_version }}"
git checkout -B $branch origin/main
git push --set-upstream origin $branch
echo "branch=${branch}" >> $GITHUB_OUTPUT
- name: Commit and push branch
run: |
git add CHANGELOG.md versions-config.json
git commit --message "DataLens release v${{ steps.gather_changelog.outputs.release_version }}"
git push origin ${{ steps.create_branch.outputs.branch }}
- name: Create PR
env:
GH_TOKEN: ${{ github.token }}
run: |
pr_body="
This PR is created by a GitHub action.
Navigate to the [release page](${{ steps.gather_changelog.outputs.release_url }}) to validate the release description.
If the description needs changing, do not edit the description manually, instead edit the \`CHANGELOG.md\` file in this PR and the release will be updated automatically.
When you are ready to confirm this release, merge this PR and publish the release (in that order, to keep release tags consistent)."
pr_link=$(gh pr create \
--title "Release DataLens v${{ steps.gather_changelog.outputs.release_version }}" \
--body "$pr_body" \
--base main \
--head ${{ steps.create_branch.outputs.branch }} \
--draft)
echo "::notice title=Created PR::$pr_link"
call_update_compose:
needs: [run]
uses: datalens-tech/datalens/.github/workflows/update-compose.yml@main
with:
pr_head: ${{ needs.run.outputs.branch }}
47 changes: 47 additions & 0 deletions .github/workflows/scripts/changelog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

## Changelog gatherer

The `releaser` script is used to create a GitHub release, including:
- update the `versions-config.json` file
- update the `CHANGELOG.md` file
- create a GitHub release itself

It gathers commits between specified tags across the repositories specified in `changelog_config.json`, matches them
with pull requests and formats their titles into a list of changes.

For a pull request to be included in the changelog, add a `changelog` label to it.

Other labels can be used to control which section the changes end up in and the component that will be mentioned.

Each pull request can be assigned to a single section – if more than one section (type) label is assigned
to a pull request, then the one that is above in the changelog-config will be chosen. A pull request can be assigned
to any number of components, they will appear in a changelog record in the order in which they are specified
in the changelog-config.

Use the following labels to assign a pull request to a section:
- `type/breaking-change` -> Breaking changes
- `type/new-feature` -> New features
- `type/bug-fix` -> Bug fixes
- `type/sec` -> Security
- `type/deprecation` -> Deprecation
- `type/dev` -> Development
- `type/tests` -> Tests
- `type/CI` -> CI
- `type/chore` -> Chores

Use the following labels to assign a pull request to a component,
which will put its name in front of the pull request title:
- `component/charts` -> Charts
- `component/connectors` -> Connectors
- `component/navigation` -> Navigation
- `component/general` -> General components
- `component/dashboards` -> Dashboards
- `component/datasets` -> Datasets
- `component/auth` -> Auth
- `component/optimization` -> Optimization
- `component/role-model` -> Role model
- `component/docs` -> Docs
- `component/formula` -> Formula

This manual is generated from a config file, `changelog_config.json`, which includes all possible labels and their role,
known repositories and texts.
133 changes: 133 additions & 0 deletions .github/workflows/scripts/changelog/changelog_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"repositories": [
{
"name": "datalens-ui",
"url": "https://github.com/datalens-tech/datalens-ui",
"images": [
{
"name": "datalens-ui",
"version_descriptor": "uiVersion"
}
]
},
{
"name": "datalens-backend",
"url": "https://github.com/datalens-tech/datalens-backend",
"images": [
{
"name": "datalens-control-api",
"version_descriptor": "controlApiVersion"
},
{
"name": "datalens-data-api",
"version_descriptor": "dataApiVersion"
}
]
},
{
"name": "datalens-us",
"url": "https://github.com/datalens-tech/datalens-us",
"images": [
{
"name": "datalens-us",
"version_descriptor": "usVersion"
}
]
}
],
"changelog_include_label": "changelog",
"images_versions_section": "Image versions",
"other_changes_section": "Other",
"single_section_title": "Changes",
"no_changes_message": "Minor improvements",
"section_tags": {
"prefix": "type/",
"tags": [
{
"id": "breaking-change",
"text": "Breaking changes"
},
{
"id": "new-feature",
"text": "New features"
},
{
"id": "bug-fix",
"text":"Bug fixes"
},
{
"id": "sec",
"text": "Security"
},
{
"id": "deprecation",
"text": "Deprecation"
},
{
"id": "dev",
"text": "Development"
},
{
"id": "tests",
"text": "Tests"
},
{
"id": "CI",
"text": "CI"
},
{
"id": "chore",
"text": "Chores"
}
]
},
"component_tags": {
"prefix": "component/",
"tags": [
{
"id": "charts",
"text":"Charts"
},
{
"id": "connectors",
"text": "Connectors"
},
{
"id": "navigation",
"text": "Navigation"
},
{
"id": "general",
"text": "General components"
},
{
"id": "dashboards",
"text": "Dashboards"
},
{
"id": "datasets",
"text": "Datasets"
},
{
"id": "auth",
"text": "Auth"
},
{
"id": "optimization",
"text": "Optimization"
},
{
"id": "role-model",
"text": "Role model"
},
{
"id": "docs",
"text": "Docs"
},
{
"id": "formula",
"text": "Formula"
}
]
}
}
16 changes: 16 additions & 0 deletions .github/workflows/scripts/changelog/clone_repos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

set -eux

CONFIG_FILE=${CONFIG_FILE}
REPOS_DIR=${REPOS_DIR:-./repos}

for repo in $(jq -c '.repositories[]' "$CONFIG_FILE"); do
repo_path="$REPOS_DIR/$(jq -r '.name' <<< $repo)"
repo_clone_url="$(jq -r '.url' <<< "$repo").git"

echo "Cloning $repo_clone_url into $repo_path"
git clone $repo_clone_url $repo_path
done

set +x
Loading

0 comments on commit e920dbd

Please sign in to comment.