From 96dcd00b86f7f3ac44e12329320cc951e85cb233 Mon Sep 17 00:00:00 2001 From: miigotu Date: Tue, 20 Sep 2022 08:12:15 -0400 Subject: [PATCH] feat: Add support for `RELEASE_BRANCH` and `CHANGELOG_FILE` environment variables Please check the readme's configuration section for details. Co-authored-by: bjoluc --- action.yml | 11 ++++++++++- readme.md | 2 ++ release.config.js | 7 +++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 2f1783d..f86cdc1 100644 --- a/action.yml +++ b/action.yml @@ -8,9 +8,16 @@ inputs: github_token: description: "A GitHub API token (to publish GitHub releases and comment on resolved issues)" required: true + pypi_repository: description: "The repository to upload your Python package to (e.g., `https://upload.pypi.org/legacy/` for PyPI, or `https://test.pypi.org/legacy/` for Test PyPI)" required: false + release_branch: + description: "The name of the Git branch to be released" + required: false + changelog_file: + description: "The path of the changelog file" + required: false runs: using: "composite" @@ -25,7 +32,9 @@ runs: - name: Release shell: bash env: - PYPI_REPOSITORY: ${{ inputs.pypi_repository }} PYPI_TOKEN: ${{ inputs.pypi_token }} GITHUB_TOKEN: ${{ inputs.github_token }} + PYPI_REPOSITORY: ${{ inputs.pypi_repository }} + RELEASE_BRANCH: ${{ inputs.release_branch }} + CHANGELOG_FILE: ${{ inputs.changelog_file }} run: npx semantic-release --extends @bjoluc/semantic-release-config-poetry diff --git a/readme.md b/readme.md index df8fb09..2353c88 100644 --- a/readme.md +++ b/readme.md @@ -60,3 +60,5 @@ Furthermore, the following optional environment variables can be set: | Environment variable | Description | Default value | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | | `PYPI_REPOSITORY` | The repository to upload your Python package to (e.g., `https://upload.pypi.org/legacy/` for PyPI, or `https://test.pypi.org/legacy/` for Test PyPI) | `https://upload.pypi.org/legacy/` | +| `RELEASE_BRANCH` | The name of the Git branch to be released | `main` | +| `CHANGELOG_FILE` | The path of the changelog file | `CHANGELOG.md` | diff --git a/release.config.js b/release.config.js index f9953d6..c0f08c2 100644 --- a/release.config.js +++ b/release.config.js @@ -1,7 +1,9 @@ const PYPI_REPOSITORY = process.env.PYPI_REPOSITORY ?? "https://upload.pypi.org/legacy/"; +const RELEASE_BRANCH = process.env.RELEASE_BRANCH ?? "main"; +const CHANGELOG_FILE = process.env.CHANGELOG_FILE ?? "CHANGELOG.md"; const config = { - branches: ["main"], + branches: [RELEASE_BRANCH], plugins: [ [ "@semantic-release/commit-analyzer", @@ -18,6 +20,7 @@ const config = { [ "@semantic-release/changelog", { + changelogFile: CHANGELOG_FILE, changelogTitle: "# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines.", }, @@ -59,7 +62,7 @@ const config = { [ "@semantic-release/git", { - assets: ["pyproject.toml", "*/__init__.py", "CHANGELOG.md"], + assets: ["pyproject.toml", "*/__init__.py", CHANGELOG_FILE], }, ], ],