Skip to content

Commit e1f0cfc

Browse files
authored
Merge pull request #146 from lumapps/fix-ci
chore(ci): fix ci to release and tag correctly
2 parents 67dca7f + f83fcbb commit e1f0cfc

File tree

6 files changed

+102
-49
lines changed

6 files changed

+102
-49
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: Pypi publish 📦
22

33
on:
44
release:
5-
types: [created]
5+
types: [published]
6+
branches:
7+
- master
68

79
jobs:
810

@@ -13,6 +15,8 @@ jobs:
1315
steps:
1416
- name: Checkout branch
1517
uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
1620

1721
- name: Setup Python 3.7 🐍
1822
uses: actions/[email protected]
@@ -29,7 +33,12 @@ jobs:
2933
key: pypi-${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
3034
restore-keys: |
3135
pypi-${{ runner.os }}-poetry-
32-
36+
37+
- name: Config git
38+
run: |
39+
git config --local user.email "[email protected]"
40+
git config --local user.name "GitHub Action"
41+
3342
- name: Set Poetry config
3443
run: |
3544
poetry config virtualenvs.in-project false
@@ -41,15 +50,26 @@ jobs:
4150

4251
- name: 📦 Build Python package and publish to PyPI 📦
4352
if: startsWith(github.ref, 'refs/tags/')
44-
run: poetry publish --build -u __token__ -p ${{ secrets.PYPI_TOKEN }}
53+
run: |
54+
poetry version ${{ github.event.release.tag_name }}
55+
poetry publish --build -u __token__ -p ${{ secrets.PYPI_TOKEN }}
56+
57+
- name: Add and commit changes
58+
if: startsWith(github.ref, 'refs/tags/')
59+
run: |
60+
git add poetry.toml
61+
git commit -m "chore(release): release version ${{ github.event.release.tag_name }}"
4562
63+
- name: Push changes
64+
uses: ad-m/github-push-action@master
65+
with:
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
4668
- name: Build doc
4769
run: make docs
4870

49-
- name: Deploy doc
50-
uses: JamesIves/[email protected]
71+
- name: Publish doc
72+
uses: peaceiris/actions-gh-pages@v3
5173
with:
52-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53-
BRANCH: gh-pages # The branch the action should deploy to.
54-
FOLDER: site # The folder the action should deploy.
55-
CLEAN: true # Automatically remove deleted files from the deploy branch
74+
github_token: ${{ secrets.GITHUB_TOKEN }}
75+
publish_dir: ./site

.github/workflows/release-note.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ name: Create release note
44
on:
55
push:
66
tags:
7-
- '[0-9]+-[0-9]+-[0-9]+'
7+
- '[0-9]+.[0-9]+.[0-9]+'
8+
branches:
9+
- master
810

911
jobs:
1012
build:
@@ -18,7 +20,7 @@ jobs:
1820

1921
- name: Generate changelog
2022
id: generate_changelog
21-
uses: lumapps/changelog-generator@master
23+
uses: sebastien-boulle/changelog-generator@master
2224
env:
2325
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2426

CONTRIBUTING.md

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
44

5-
## Environment setup
5+
## __Environment setup__
66

77
First install dependencies and setup pre-commits hooks
88

@@ -20,9 +20,9 @@ To add a dependency use poetry
2020
poetry add <dependency>
2121
```
2222

23-
## Dev
23+
## __Dev__
2424

25-
### Code
25+
### __Code__
2626

2727
First open an issue to discuss the matter before coding.
2828
When your idea has been approved, create a new branch `git checkout -b <new_branch_name>` and open a Pull Request.
@@ -34,13 +34,52 @@ make check
3434
make test
3535
```
3636

37-
## Commits format
37+
### __Commits format__
3838

3939
Commits format is enforced according to the tool https://github.com/lumapps/commit-message-validator
4040

41-
A pre-commit hook as well as an action will check that for you and PR need to respect that format to be merged.
41+
Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:
4242

43-
### Documentation
43+
```
44+
<type>(<scope>): <subject>
45+
<BLANK LINE>
46+
<body>
47+
<BLANK LINE>
48+
<footer>
49+
```
50+
51+
* The first line of the commit message (the "Subject") cannot be longer than 70 characters.
52+
* Any other line of the commit message cannot be longer 100 characters!
53+
* The body and footer are optional, but depends on the type, information can be mandatory.
54+
55+
This allows the message to be easier to read on github as well as in various git tools.
56+
57+
58+
**Type**
59+
60+
Must be one of the following:
61+
62+
* feat: A new feature
63+
* fix: A bug fix
64+
* docs: Documentation only changes
65+
* lint: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc)
66+
* refactor: A code change that neither fixes a bug or adds a feature
67+
* test: Adding missing tests or correcting existing tests
68+
* chore: Changes to the build process or auxiliary tools and libraries such as distribution generation
69+
70+
Example:
71+
```
72+
feat(toto-service): provide toto for all
73+
74+
Before we had to do another thing. There was this and this problem.
75+
Now, by using "toto", it's simpler and the problems are managed.
76+
```
77+
78+
> More: For more informations about the commit format see [here](https://github.com/lumapps/commit-message-validator#commit-message-format)
79+
80+
>Note: A pre-commit hook as well as an action will check that for you and PR need to respect that format to be merged.
81+
82+
## __Documentation__
4483

4584
Additionnaly to edit the documentation you can add/modify markdown files in the docs folder.
4685
You can preview the doc by running
@@ -49,13 +88,33 @@ You can preview the doc by running
4988
make docs-serve
5089
```
5190

52-
Then to deploy the doc you cna run
91+
Then to deploy the doc you can run
5392

5493
```bash
5594
make doc-deploy
5695
```
5796

5897

59-
## Deploy to pypi
98+
## __Deploy a new version (admins)__
99+
100+
101+
### __Regular release__
102+
103+
Simply create and push the tag X.Y.Z on master.
104+
105+
```
106+
git tag X.Y.Z
107+
git push origin master X.Y.Z
108+
```
109+
110+
This will create a draft release, you'll then need to publish it.
111+
112+
![](docs/static/publish-release.gif)
113+
114+
Finally the CI will release the corresponding package version on Pypi, bump the version and publish the doc for you.
115+
116+
### __Beta release__
117+
118+
Doing a beta release is a bit different, we do not use tag automation for the time being.
60119

61-
When a tagged is pushed the ci will create a release draft and then another workflow will be trigger that will deploy to pypi the version tagged and also deploy the documentation
120+
Simply publish a pre-release on github with the correct tag (eg, 1.1.3b1) and this will trigger the publication on Pypi

Makefile

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,6 @@ format: ## Run formatting tools on the code.
6565
@poetry run failprint -t "Formatting code" -- black $(PY_SRC)
6666
@poetry run failprint -t "Ordering imports" -- isort -y -rc $(PY_SRC)
6767

68-
.PHONY: release
69-
release: ## Create a new release (commit, tag, push, build, publish, deploy docs).
70-
ifndef v
71-
$(error Pass the new version with 'make release v=0.0.0')
72-
endif
73-
-@if ! $(CI) && ! $(TESTING); then \
74-
poetry run failprint -t "Bumping version" -- poetry version $(v); \
75-
poetry run failprint -t "Staging files" -- git add pyproject.toml CHANGELOG.md; \
76-
poetry run failprint -t "Committing changes" -- git commit -m "chore: Prepare release $(v)" --no-verify; \
77-
poetry run failprint -t "Tagging commit" -- git tag v$(v); \
78-
fi
79-
poetry run failprint -t "Building dist/wheel" -- poetry build
80-
-@if ! $(CI) && ! $(TESTING); then \
81-
poetry run failprint -t "Pushing commits" -- git push; \
82-
poetry run failprint -t "Pushing tags" -- git push --tags; \
83-
poetry publish; \
84-
poetry run failprint -t "Deploying docs" -- poetry run mkdocs gh-deploy; \
85-
fi
8668

8769
.PHONY: setup
8870
setup: ## Setup the development environment (install dependencies).
@@ -108,13 +90,3 @@ test: ## Run the test suite and report coverage. 2>/dev/null
10890
@poetry run coverage html --rcfile=config/coverage.ini
10991

11092

111-
.PHONY: pypi-release-beta
112-
pypi-release-beta: # release to pypi without taging github
113-
ifndef v
114-
$(error Pass the new version with 'make release v=0.0.0')
115-
endif
116-
@poetry run failprint -t "Bumping version" -- poetry version $(v)
117-
@poetry run failprint -t "Building dist/wheel" -- poetry build
118-
-@if ! $(CI) && ! $(TESTING); then \
119-
poetry publish; \
120-
fi

docs/static/publish-release.gif

482 KB
Loading

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ python = "^3.6.4"
1919
Authlib = "^0.14.3"
2020
python-slugify = "^4.0.1"
2121
httpx = "^0.15.*"
22-
pytest-httpx = "^0.9.0"
2322

2423
[tool.poetry.dev-dependencies]
2524
flake8 = "^3.8.3"
@@ -40,6 +39,7 @@ black = "^19.10b0"
4039
isort = { version = "^4.3", extras = ["pyproject"] }
4140
safety = "^1.9.0"
4241
pytest-cov = "^2.9.0"
42+
pytest-httpx = "^0.9.0"
4343

4444
[tool.black]
4545
line-length = 88

0 commit comments

Comments
 (0)