Skip to content

Commit cde712f

Browse files
committed
chore: enable github action for validation and releasing
Signed-off-by: Takumi Yanagawa <yana@jp.ibm.com>
1 parent e6da37c commit cde712f

File tree

5 files changed

+145
-20
lines changed

5 files changed

+145
-20
lines changed

.github/workflows/release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# GitHub recommends pinning actions to a commit SHA.
7+
# To get a newer version, you will need to update the SHA.
8+
# You can also reference a tag or branch, but the action may change without warning.
9+
10+
name: release
11+
12+
on:
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
name: Build with semantic versioning
18+
runs-on: ubuntu-latest
19+
outputs:
20+
release-tag: ${{ steps.release.outputs.tag }}
21+
release-version: ${{ steps.release.outputs.version }}
22+
permissions:
23+
contents: write
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
- name: Install semantic-release
30+
run: pip install python-semantic-release==9.21.0
31+
- name: Python Semantic Release
32+
id: release
33+
env:
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: |
36+
semantic-release version --patch --print > version.txt
37+
semantic-release version --patch
38+
TAG="v$(cat version.txt)"
39+
echo "tag=$TAG" >> $GITHUB_OUTPUT
40+
echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
41+
- name: Check release
42+
if: steps.release.outputs.released == 'false'
43+
run: |
44+
echo 'No release will be made since there are no release commits. See also Commit Parsers configuration.'
45+
exit 1
46+
- name: Set up Python 3.11
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: '3.11'
50+
- name: Install build tools
51+
run: |
52+
make install-dev
53+
- name: Build
54+
run: |
55+
make build
56+
- name: Store the distribution packages
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: python-package-distributions
60+
path: dist/
61+
62+
publish-to-github:
63+
name: Publish to GitHub
64+
needs:
65+
- build
66+
runs-on: ubuntu-latest
67+
68+
permissions:
69+
contents: write
70+
packages: write
71+
id-token: write # IMPORTANT: mandatory for trusted publishing
72+
73+
steps:
74+
- name: Download all the dists
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: python-package-distributions
78+
path: dist/
79+
- name: Sign the dists with Sigstore
80+
uses: sigstore/gh-action-sigstore-python@v3.0.0
81+
with:
82+
inputs: |
83+
./dist/*.tar.gz
84+
./dist/*.whl
85+
- name: Upload package distributions to GitHub Releases
86+
run: gh release upload ${{needs.build.outputs.release-tag}} ./dist/*
87+
env:
88+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
GH_REPO: ${{ github.REPOSITORY }}

.github/workflows/validate.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# GitHub recommends pinning actions to a commit SHA.
7+
# To get a newer version, you will need to update the SHA.
8+
# You can also reference a tag or branch, but the action may change without warning.
9+
10+
name: validate
11+
12+
on:
13+
pull_request_target:
14+
types:
15+
- opened
16+
- edited
17+
- synchronize
18+
branches:
19+
- 'main'
20+
21+
jobs:
22+
validate:
23+
name: Validate
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
repository: ${{ github.event.pull_request.head.repo.full_name }}
30+
ref: ${{ github.event.pull_request.head.ref }}
31+
- name: Set up Python 3.11
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.11'
35+
- name: Install for develompemnt
36+
run: |
37+
make install-dev
38+
- name: Unit Test
39+
run: |
40+
make test

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ test:
88
format:
99
python -m black .
1010

11+
.PHONY: build
12+
build:
13+
python -m build
14+
15+
.PHONY: install-dev
16+
install-dev:
17+
python -m pip install -e ".[dev]"
18+
1119
# Direct dependency is not allowed for Pypi packaging even if the dependant module is defined as extra dependencies.
1220
# Workaround: Move to manual installation by make
1321
.PHONY: install-detect-descret

itbench_tools/__version__.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

pyproject.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ requires = ["setuptools", "setuptools-scm"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6+
version = "0.0.1"
67
name = "itbench-tools"
78
requires-python = ">=3.11"
89
keywords = ["one", "two"]
@@ -21,8 +22,6 @@ dependencies = [
2122
"urllib3>=2.2.2",
2223
]
2324

24-
dynamic = ["version"]
25-
2625
[project.scripts]
2726
itbench-tools = "itbench_tools.main:main"
2827

@@ -39,9 +38,6 @@ dev = [
3938
"isort",
4039
]
4140

42-
[tool.setuptools.dynamic]
43-
version = {attr = "itbench_tools.__version__.__version__"}
44-
4541
[tool.setuptools]
4642
package-dir = { "itbench_tools" = "itbench_tools" }
4743

@@ -84,5 +80,12 @@ exclude = '''
8480
ignore = "E203, W503,"
8581
max-line-length = 150
8682

83+
[tool.semantic_release]
84+
commit_message = "{version}\n\nAutomatically generated by python-semantic-release"
85+
version_toml = ["pyproject.toml:project.version"]
86+
87+
[tool.semantic_release.remote.token]
88+
env = "GITHUB_TOKEN"
89+
8790
[tool.semantic_release.publish]
8891
upload_to_vcs_release = false

0 commit comments

Comments
 (0)