Skip to content

Commit

Permalink
ci: improve release procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed May 19, 2024
1 parent ef2e0f9 commit 482eccd
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name: Build and deploy for develop

trigger:
branch:
- develop
- relay.md/develop
status:
# Only runs if the first pipeline was fully successful
- success
Expand Down Expand Up @@ -83,7 +83,7 @@ name: semantic-version
depends_on:
- run_tests
trigger:
branch: master
branch: relay.md/master
event: push
status:
# Only runs if the first pipeline was fully successful
Expand All @@ -92,7 +92,7 @@ steps:
- name: semver
image: python:3.8
commands:
- pip3 install python-semantic-release==7.28.0
- pip3 install -U python-semantic-release
- semantic-release publish

---
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Build

on:
workflow_call:
inputs:
version:
required: true
type: string
registry:
required: true
type: string
image:
required: true
type: string
jobs:

build:
name: Build and Push docker container
runs-on: ubuntu-latest

# Required to write to ghcr.io
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: 'Login to GitHub Container Registry'
uses: docker/[email protected]
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.version }}
build-args: |
VCS_REF=${{ github.sha }}
20 changes: 20 additions & 0 deletions .github/workflows/develop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test, build and deploy for Test

on:
push:
branches:
- develop

jobs:

test:
uses: ./.github/workflows/test.yaml

build:
uses: ./.github/workflows/build.yaml
secrets: inherit
needs: test
with:
version: "${{ github.ref_name }}.${{ github.run_number }}"
registry: ghcr.io
image: relay-md/relay.md
25 changes: 25 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Semantic Release

on:
push:
branches:
- master

jobs:

release:
runs-on: ubuntu-latest
concurrency: release
permissions:
id-token: write
contents: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Release
uses: python-semantic-release/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Test

on:
workflow_call:

jobs:

test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: [3.8, 3.9]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
59 changes: 59 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[tool.semantic_release]
assets = []
build_command_env = []
commit_message = "{version}\n\nAutomated 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

[tool.semantic_release.branches.relay-md]
match = "relay-md/master"
prerelease_token = "rc"
prerelease = false
tag_format = "r{version}"

[tool.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"]
default_bump_level = 0

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

[tool.semantic_release.publish]
dist_glob_patterns = ["dist/*"]
upload_to_vcs_release = true
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ coverage
flake8

# Releases
python-semantic-release==7.28.0
python-semantic-release>=9.7,<10

# mypy
mypy
Expand Down
7 changes: 0 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ per-file-ignores =
# need to patch config before importing other stuff that load config already
tests/conftest.py:E402

[semantic_release]
version_variable = setup.py:__version__,backend/__init__.py:__version__
upload_to_repository = false
upload_to_pypi = false
upload_to_release = false
branch = relay.md/master

[mypy]
ignore_missing_imports = True
exclude =
Expand Down

0 comments on commit 482eccd

Please sign in to comment.