Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release-please): release-please as a new option for release automation (WIP) #304

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/scicookie/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
],
"governance_document": ["None", "numpy-governance", "sciml-governance"],
"roadmap_document": ["None", "pytorch-ignite-roadmap"],
"release_workflow": ["semantic-release", "release-please", "None"],
"build_system": [
"poetry",
"flit",
Expand Down
13 changes: 13 additions & 0 deletions src/scicookie/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@
BUILD_SYSTEM = None
{%- endif %}

ALL_RELEASE_DIRS = [
PROJECT_DIRECTORY / 'release-semantic',
PROJECT_DIRECTORY / 'release-please',
]

{% if cookiecutter.release_workflow == "semantic-release" -%}
RELEASE_PATH = PROJECT_DIRECTORY / '.github' / 'workflows' / 'release.yaml'
{% if cookiecutter.release_workflow == "release-please" -%}
RELEASE_PATH = PROJECT_DIRECTORY / '.github' / 'workflows' / 'release-please.yaml'
{% else %}
RELEASE_PATH = None
{%- endif %}


def remove_dirs(dirs: list):
for dirs in dirs:
Expand Down
12 changes: 12 additions & 0 deletions src/scicookie/profiles/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@ roadmap_document:
- pytorch-ignite-roadmap
visible: true

release_workflow:
message: Select one option for release automation tool for this project
help: "For more information, check:\n https://osl-incubator.github.io/scicookie/guide/#release-workflow"
type: single-choice
default: None
# first choice is the default for the UI
choices:
- None
- semantic-release
- release-please
visible: true

git_username:
message: Type the GIT username
help: https://osl-incubator.github.io/scicookie/guide/#control-version
Expand Down
4 changes: 4 additions & 0 deletions src/scicookie/profiles/osl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ roadmap_document:
default: None
visible: false

release_workflow:
default: semantic-release
visible: false

git_username:
default: yorbriar
visible: true
Expand Down
18 changes: 18 additions & 0 deletions src/scicookie/{{cookiecutter.project_slug}}/.makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ groups:
vars:
app: |
npx --yes \
{%- if cookiecutter.release_workflow == "semantic-release" %}
-p semantic-release \
-p "@semantic-release/commit-analyzer" \
-p "@semantic-release/release-notes-generator" \
Expand All @@ -130,12 +131,29 @@ groups:
-p "@semantic-release/git" \
-p "@google/semantic-release-replace-plugin" \
semantic-release
{%- if cookiecutter.release_workflow == "release-please" %}
-p release-please \
-p release-please release-pr
--token=$GITHUB_TOKEN \
--repo-url={{ cookiecutter.git_username }}/{{ cookiecutter.git_main_branch }} --config-file
release-please github-release \
--token=$GITHUB_TOKEN
--repo-url={{ cookiecutter.git_username }}/{{ cookiecutter.git_main_branch }} --config-file
release-please

tasks:
ci:
{%- if cookiecutter.release_workflow == "semantic-release" %}
help: run semantic release on CI
run: {{ "${{ vars.app }} --ci" }}
{%- if cookiecutter.release_workflow == "release-please" %}
help: run release please on CI
run: {{ "${{ vars.app }}" }}

dry:
{%- if cookiecutter.release_workflow == "semantic-release" %}
help: run semantic release in dry-run mode
run: {{ "${{ vars.app }} --dry-run" }}
{%- if cookiecutter.release_workflow == "release-please" %}
help: run release please in dry-run mode
run: {{ "${{ vars.app }} --dry-run" }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@
{% set package_path = cookiecutter.package_slug -%}
{% endif -%}
{% set cpp_path = "src" -%}
{% if cookiecutter.release_workflow == "semantic-release -%}
project(
'{{ cookiecutter.project_slug }}',
'cpp',
version: '{{ cookiecutter.project_version }}', # semantic-release
license: '{{ cookiecutter.project_license }}',
meson_version: '>= 1.1.0',
)
{% endif -%}
{% if cookiecutter.release_workflow == "release-please -%}
project(
'{{ cookiecutter.project_slug }}',
'cpp',
version: '{{ cookiecutter.project_version }}', # release-please
license: '{{ cookiecutter.project_license }}',
meson_version: '>= 1.1.0',
)
{% endif -%}
name = '{{ cookiecutter.package_slug }}'

cpp_sources = files('src/main.cpp')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

[tool.poetry]
name = "{{ cookiecutter.project_slug }}"
{% if cookiecutter.release_workflow == "semantic-release" -%}
version = "{{ cookiecutter.project_version }}" # semantic-release
{% endif -%}
{% if cookiecutter.release_workflow == "release-please" -%}
version = "{{ cookiecutter.project_version }}" # release-please
{% endif -%}
description = "{{ cookiecutter.project_short_description }}"
readme = "README.md"
authors = ["{{ cookiecutter.author_full_name }} <{{ cookiecutter.author_email }}>"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: release-please

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: write
issues: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
timeout-minutes: 10

defaults:
run:
shell: bash -l {0}

steps:
- uses: googleapis/release-please-action@v4
with:
# this assumes that you have created a personal access token
# (PAT) and configured it as a GitHub action secret named
# `MY_RELEASE_PLEASE_TOKEN`.
token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
config-file: release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
- pybind11
- cmake
{%- endif %}
- nodejs # used by semantic-release
- nodejs # used by semantic-release and release-please
{%- if cookiecutter.use_shellcheck == "yes" %}
- shellcheck
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cmake
pybind11
cmake
{%- endif %}
nodejs # used by semantic-release
nodejs # used by semantic-release and release-please
{%- if cookiecutter.use_shellcheck == "yes" %}
shellcheck
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ def get_version() -> str:
try:
return importlib_metadata.version(__name__)
except importlib_metadata.PackageNotFoundError: # pragma: no cover
{%- if cookiecutter.release_worlflow == "semantic-release" %}
return {{ QUOTE }}{{ cookiecutter.project_version }}{{ QUOTE }} # semantic-release
{%- endif %}
{%- if cookiecutter.release_worlflow == "release-please" %}
return {{ QUOTE }}{{ cookiecutter.project_version }}{{ QUOTE }} # release-please
{%- endif %}


version = get_version()
Expand Down
Loading