Skip to content

Commit

Permalink
Merge pull request #1 from opentargets/new-branch
Browse files Browse the repository at this point in the history
ci: ci test release
  • Loading branch information
project-defiant authored Aug 13, 2024
2 parents bac9b9d + 7fbd06c commit 1e07aa5
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 11 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.10.8
- name: Install the latest version of rye
run: make dev
- name: Install uv
uses: yezz123/setup-uv@v4
- name: Install rye
uses: eifinger/setup-rye@v4
with:
version: "latest"
- name: Sync dependencies
run: rye sync
- name: Run checks
- uses: pre-commit/action@v3.0.1
run: rye run pre-commit run --all-files
45 changes: 45 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
push:
tags:
- "v*"

env:
PYTHON_VERSION_DEFAULT: "3.10.8"

jobs:
release:
runs-on: ubuntu-latest
environment: PyPI
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
contents: write
steps:
- uses: actions/create-github-app-token@v1
id: trigger-token
with:
app-id: ${{ vars.TRIGGER_WORKFLOW_GH_APP_ID}}
private-key: ${{ secrets.TRIGGER_WORKFLOW_GH_APP_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.8
- name: Install uv
uses: yezz123/setup-uv@v4
- name: Install rye
uses: eifinger/setup-rye@v4
with:
version: "latest"
- name: Sync dependencies
run: rye sync
- name: Build package
run: make build
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/gentroutils/
packages-dir: dist/
34 changes: 34 additions & 0 deletions .github/workflows/release_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PR to trigger release

"on":
schedule:
- cron: "15 16 * * 4"

jobs:
pull-request:
runs-on: ubuntu-latest
environment: PyPI
steps:
- uses: actions/create-github-app-token@v1
id: trigger-token
with:
app-id: ${{ vars.TRIGGER_WORKFLOW_GH_APP_ID}}
private-key: ${{ secrets.TRIGGER_WORKFLOW_GH_APP_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
repository: opentargets/gentropy
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- uses: actions/checkout@v3
- name: pull-request
uses: diillson/auto-pull-request@v1.0.1
with:
source_branch: "dev"
destination_branch: "main"
pr_title: "chore: trigger release process"
pr_body: ":warning: *This PR requires a MERGE COMMIT (Don't squash or rebase!)*"
pr_label: "auto-pr"
pr_draft: false
pr_allow_empty: true
github_token: ${{ secrets.GITHUB_TOKEN }}
53 changes: 53 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

"on":
push:
branches: ["main"]

concurrency:
group: deploy
cancel-in-progress: false # prevent hickups with semantic-release

env:
PYTHON_VERSION_DEFAULT: "3.10.8"

jobs:
release:
runs-on: ubuntu-latest
concurrency: release
environment: PyPI
permissions:
contents: write

steps:
# NOTE: commits using GITHUB_TOKEN does not trigger workflows
- uses: actions/create-github-app-token@v1
id: trigger-token
with:
app-id: ${{ vars.TRIGGER_WORKFLOW_GH_APP_ID}}
private-key: ${{ secrets.TRIGGER_WORKFLOW_GH_APP_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
repository: opentargets/gentropy
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false

- name: Python Semantic Release
id: semrelease
# v9.6.0 is required due to the python v3.12 in the newer version of semantic release action which
# breaks the poetry build command.
uses: python-semantic-release/python-semantic-release@v9.6.0
with:
github_token: ${{ steps.trigger-token.outputs.token }}

- name: Publish package to GitHub Release
uses: python-semantic-release/upload-to-gh-release@main
if: ${{ steps.semrelease.outputs.released }} == 'true'
with:
# NOTE: allow to start the workflow when push action on tag gets executed
# requires using GH_APP to authenitcate, otherwise push authorised with
# the GITHUB_TOKEN does not trigger the tag artifact workflow.
# see https://github.com/actions/create-github-app-token
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.semrelease.outputs.tag }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SHELL := /bin/bash
.PHONY: $(shell sed -n -e '/^$$/ { n ; /^[^ .\#][^ ]*:/ { s/:.*$$// ; p ; } ; }' $(MAKEFILE_LIST))
VERSION := $$(grep '^version' pyproject.toml | sed 's%version = "\(.*\)"%\1%')
APP_NAME := $$(grep '^name' pyproject.toml | sed 's%name = "\(.*\)"%\1%')
APP_NAME := $$(grep '^name' pyproject.toml | head -1 | sed 's%name = "\(.*\)"%\1%')

.DEFAULT_GOAL := help

Expand Down
67 changes: 66 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "gentroutils"
version = "0.1.0"
version = "0.0.0"
description = "Add your description here"
authors = [
{ name = "Szymon Szyszkowski", email = "ss60@mib117351s.internal.sanger.ac.uk" },
Expand Down Expand Up @@ -126,3 +126,68 @@ warn_unused_ignores = true
[[tool.mypy.overrides]]
module = ["google.cloud", "pyfiglet", "click", "google.cloud.storage"]
ignore_missing_imports = true


[tool.semantic_release]
version_toml = ["pyproject.tolm:project.version"]
assets = []
commit_message = "{version}\n\nAutomatically generated by python-semantic-release"
commit_parser = "angular"
logging_use_named_masks = false
major_on_zero = true
allow_zero_version = true
tag_format = "v{version}"

[tool.semantic_release.branches.main]
match = "(main|master)"
prerelease_token = "rc"
prerelease = false

[semantic_release.changelog]
template_dir = "templates"
changelog_file = "CHANGELOG.md"
exclude_commit_patterns = []

[tool.semantic_release.changelog.environment]
block_start_string = "{%"
block_end_string = "%}"
variable_start_string = "{{"
variable_end_string = "}}"
comment_start_string = "{#"
comment_end_string = "#}"
trim_blocks = false
lstrip_blocks = false
newline_sequence = "\n"
keep_trailing_newline = false
extensions = []
autoescape = true

[tool.semantic_release.commit_author]
env = "GIT_COMMIT_AUTHOR"
default = "semantic-release <semantic-release>"

[tool.semantic_release.commit_parser_options]
allowed_tags = [
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"style",
"refactor",
"test",
]
minor_tags = ["feat"]
patch_tags = ["fix", "perf", "docs", "style", "test", "ci"]
default_bump_level = 0

[tool.semantic_release.remote]
name = "origin"
type = "github"
ignore_token_for_push = false

[tool.semantic_release.publish]
dist_glob_patterns = ["dist/*"]
upload_to_vcs_release = true
13 changes: 7 additions & 6 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
# It is intended to be run on a new system to quickly set up Rye.
# It is recommended to review the script before running it.

export SHELL_RC=$(echo "$HOME/.${SHELL##*/}rc")

export SHELL_ZSH=$(echo "$HOME/.${SHELL##*/}rc")

if ! command -v rye &> /dev/null; then
if ! command -v rye &>/dev/null; then
echo "Rye is not installed. Installing..."
curl -sSf https://rye.astral.sh/get | bash
echo "Updating $SHELL_ZSH"
echo "source $HOME/.rye/env" >> $SHELL_ZSH
echo "Updating $SHELL_RC"
echo "source $HOME/.rye/env" >>$SHELL_RC
echo "source $HOME/.cargo/bin" >>$SHELL_RC
else
echo "Rye is already installed."
fi

if ! command -v uv &> /dev/null; then
if ! command -v uv &>/dev/null; then
echo "uv is not installed. Installing..."
curl -LsSf https://astral.sh/uv/install.sh | sh
else
echo "uv is already installed."
fi
source $SHELL_RC
rye sync
rye run pre-commit install --hook-type commit-msg --hook-type pre-commit

Expand Down

0 comments on commit 1e07aa5

Please sign in to comment.