Skip to content

Commit 92cd040

Browse files
committed
ci: add ci workflow to manage lib release with semantic-release
Signed-off-by: Simone Pulcini <[email protected]>
1 parent 1ae5d26 commit 92cd040

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

.github/workflows/release.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- pre/*
7+
pull_request:
8+
types: [closed]
9+
10+
permissions:
11+
contents: write # for checkout
12+
13+
jobs:
14+
build:
15+
name: Build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Install git
19+
run: |
20+
sudo apt update
21+
sudo apt install -y git
22+
- name: Install Python Env and Poetry
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.9.19'
26+
- run: pip install poetry
27+
- name: Install Node Env
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
- name: Checkout
32+
uses: actions/[email protected]
33+
with:
34+
fetch-depth: 0
35+
persist-credentials: false
36+
- name: Build app
37+
run: |
38+
poetry install
39+
poetry build
40+
id: build_cache
41+
if: success()
42+
- name: Cache build
43+
uses: actions/cache@v2
44+
with:
45+
path: ./dist
46+
key: ${{ runner.os }}-build-${{ hashFiles('dist/**') }}
47+
if: steps.build_cache.outputs.id != ''
48+
49+
release:
50+
name: Release
51+
runs-on: ubuntu-latest
52+
needs: build
53+
environment: development
54+
if: |
55+
github.event_name == 'push' && github.ref == 'refs/heads/main' ||
56+
github.event_name == 'push' && github.ref == 'refs/heads/pre/beta' ||
57+
github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'main' ||
58+
github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'pre/beta'
59+
permissions:
60+
contents: write
61+
issues: write
62+
pull-requests: write
63+
id-token: write
64+
steps:
65+
- name: Checkout repo
66+
uses: actions/[email protected]
67+
with:
68+
fetch-depth: 0
69+
persist-credentials: false
70+
- name: Semantic Release
71+
uses: cycjimmy/[email protected]
72+
with:
73+
semantic_version: 23
74+
extra_plugins: |
75+
semantic-release-pypi
76+
@semantic-release/git
77+
@semantic-release/commit-analyzer
78+
@semantic-release/release-notes-generator
79+
@semantic-release/github
80+
@semantic-release/changelog
81+
conventional-changelog-conventionalcommits
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

.releaserc.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
plugins:
2+
- - "@semantic-release/commit-analyzer"
3+
- preset: conventionalcommits
4+
- - "@semantic-release/release-notes-generator"
5+
- writerOpts:
6+
commitsSort:
7+
- subject
8+
- scope
9+
preset: conventionalcommits
10+
presetConfig:
11+
types:
12+
- type: feat
13+
section: Features
14+
- type: fix
15+
section: Bug Fixes
16+
- type: chore
17+
section: chore
18+
- type: docs
19+
section: Docs
20+
- type: style
21+
hidden: true
22+
- type: refactor
23+
section: Refactor
24+
- type: perf
25+
section: Perf
26+
- type: test
27+
section: Test
28+
- type: build
29+
section: Build
30+
- type: ci
31+
section: CI
32+
- "@semantic-release/changelog"
33+
- "semantic-release-pypi"
34+
- "@semantic-release/github"
35+
- - "@semantic-release/git"
36+
- assets:
37+
- CHANGELOG.md
38+
- pyproject.toml
39+
message: |-
40+
ci(release): ${nextRelease.version} [skip ci]
41+
42+
${nextRelease.notes}
43+
branches:
44+
#child branches coming from tagged version for bugfix (1.1.x) or new features (1.x)
45+
#maintenance branch
46+
- name: "+([0-9])?(.{+([0-9]),x}).x"
47+
channel: "stable"
48+
#release a production version when merging towards main
49+
- name: "main"
50+
channel: "stable"
51+
#prerelease branch
52+
- name: "pre/beta"
53+
channel: "dev"
54+
prerelease: "beta"
55+
debug: true
56+

0 commit comments

Comments
 (0)