-
-
Notifications
You must be signed in to change notification settings - Fork 8
92 lines (91 loc) · 3.65 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Release
on:
push:
branches: [main, next, beta, alpha, '*.x']
jobs:
release:
name: Release
if: github.repository_owner == 'juftin'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Hatch
run: |
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch -v env create
hatch --version
- name: Release
run: hatch run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
github-pages-publish:
needs: release
if: github.ref == 'refs/heads/main' && github.repository_owner == 'juftin'
runs-on: ubuntu-latest
steps:
- name: Checkout Latest Changes
uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/main
ref: ${{ github.ref }}
fetch-depth: 0
- name: Create gh-pages if not exists
working-directory: ${{ github.workspace }}/main
run: |
git checkout gh-pages || git checkout -b gh-pages
git push --set-upstream origin gh-pages || true
git checkout main --
- name: Checkout gh-pages Branch
uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/github-pages
ref: gh-pages
fetch-depth: 0
- name: Set up Python Environment
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Hatch
working-directory: ${{ github.workspace }}/main
run: |
python -m pip install --upgrade pip
python -m pip install -q hatch
hatch -v env create
hatch --version
- name: Documentation Generation
working-directory: ${{ github.workspace }}/main
run: |
hatch run docs-build
- name: Setup Git Config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Get Commit SHA from main
working-directory: ${{ github.workspace }}/main
run: |
COMMIT_SHA=$(git rev-parse HEAD)
PROJECT_VERSION=$(hatch version)
echo PROJECT_VERSION=${PROJECT_VERSION} >> $GITHUB_ENV
echo "COMMIT_SHA=${COMMIT_SHA}" >> ${GITHUB_ENV}
- name: Commit Changes to gh-pages Branch
working-directory: ${{ github.workspace }}/github-pages
run: |
git rm -rf . || true
cp -R ${{ github.workspace }}/main/docs/_build/html/* ${PWD}
touch .nojekyll
cp ${{ github.workspace }}/main/docs/README.md .
git add .
git diff-index --quiet HEAD || git commit -m "GitHub Pages - ${{ env.PROJECT_VERSION }} - ${{ env.COMMIT_SHA }}"
git push origin gh-pages --force