Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e2c7303

Browse files
woileLee-W
authored andcommitted
docs(tutorial/github_action): explain how to create a github release
1 parent 3b591f0 commit e2c7303

File tree

1 file changed

+48
-22
lines changed

1 file changed

+48
-22
lines changed

docs/tutorials/github_actions.md

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ the new tag, back to your master branch, we have to:
77

88
1. Create a personal access token. [Follow the instructions here](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line#creating-a-token). And copy the generated key
99
2. Create a secret called `PERSONAL_ACCESS_TOKEN`, with the copied key, by going to your
10-
project repository and then `Settings > Secrets > Add new secret`.
10+
project repository and then `Settings > Secrets > Add new secret`.
1111
3. In your repository create a new file `.github/workflows/bumpversion.yml`
12-
with the following content.
12+
with the following content.
1313

1414
!!! warning
15-
If you use `GITHUB_TOKEN` instead of `PERSONAL_ACCESS_TOKEN`, the job won't trigger another workflow. It's like using `[skip ci]` in other CI's.
15+
If you use `GITHUB_TOKEN` instead of `PERSONAL_ACCESS_TOKEN`, the job won't trigger another workflow. It's like using `[skip ci]` in other CI's.
1616

1717
```yaml
1818
name: Bump version
@@ -31,17 +31,43 @@ jobs:
3131
- name: Check out
3232
uses: actions/checkout@v2
3333
with:
34-
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
34+
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
3535
fetch-depth: 0
3636
- name: Create bump and changelog
3737
uses: commitizen-tools/commitizen-action@master
3838
with:
3939
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
40-
4140
```
4241
4342
Push to master and that's it.
4443
44+
### Creating a github release
45+
46+
You can modify the previous action.
47+
48+
Add the variable `changelog_increment_filename` in the `commitizen-action`, specifying
49+
where to output the content of the changelog for the newly created version.
50+
51+
And then add a step using a github action to create the release: `softprops/action-gh-release`
52+
53+
The commitizen action creates an env variable called `REVISION`, containing the
54+
newely created version.
55+
56+
```yaml
57+
- name: Create bump and changelog
58+
uses: commitizen-tools/commitizen-action@master
59+
with:
60+
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
61+
changelog_increment_filename: body.md
62+
- name: Release
63+
uses: softprops/action-gh-release@v1
64+
with:
65+
body_path: "body.md"
66+
tag_name: ${{ env.REVISION }}
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
```
70+
4571
### Publishing a python package
4672

4773
Once the new tag is created, triggering an automatic publish command would be desired.
@@ -62,28 +88,28 @@ name: Upload Python Package
6288
on:
6389
push:
6490
tags:
65-
- '*' # Will trigger for every tag, alternative: 'v*'
91+
- "*" # Will trigger for every tag, alternative: 'v*'
6692
6793
jobs:
6894
deploy:
6995
runs-on: ubuntu-latest
7096
steps:
71-
- uses: actions/checkout@v1
72-
- name: Set up Python
73-
uses: actions/setup-python@v1
74-
with:
75-
python-version: '3.x'
76-
- name: Install dependencies
77-
run: |
78-
python -m pip install --pre -U poetry
79-
poetry --version
80-
poetry install
81-
- name: Build and publish
82-
env:
83-
PYPI_USERNAME: __token__
84-
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
85-
run: |
86-
./scripts/publish
97+
- uses: actions/checkout@v1
98+
- name: Set up Python
99+
uses: actions/setup-python@v1
100+
with:
101+
python-version: "3.x"
102+
- name: Install dependencies
103+
run: |
104+
python -m pip install --pre -U poetry
105+
poetry --version
106+
poetry install
107+
- name: Build and publish
108+
env:
109+
PYPI_USERNAME: __token__
110+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
111+
run: |
112+
./scripts/publish
87113
```
88114

89115
Notice that we are calling a bash script in `./scripts/publish`, you should configure it with your tools (twine, poetry, etc.). Check [commitizen example](https://github.com/commitizen-tools/commitizen/blob/master/scripts/publish)

0 commit comments

Comments
 (0)