-
Notifications
You must be signed in to change notification settings - Fork 29
142 lines (124 loc) · 4.4 KB
/
deploy-stable.yml
File metadata and controls
142 lines (124 loc) · 4.4 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: deploy-stable
on:
# Currently this workflow only runs when triggered manually. Perhaps we can set it up to run when a tag is pushed. Or when a release is made. Or that it could create a release, on a release it can create a tag?
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
level:
description: "The level of release to make"
required: true
type: choice
default: "patch"
options:
- "patch"
- "minor"
- "major"
branch:
description: "Use main branch for regular releases, legacy-support for 1.8x fixes."
required: false
type: choice
default: "main"
options:
- "main"
- "legacy-support"
core-repo:
description: "The repository to use for the core commit."
required: false
type: choice
default: "PreTeXtbook/pretext"
options:
- "PreTeXtbook/pretext"
- "oscarlevin/pretext"
jobs:
tests:
name: Run tests
uses: ./.github/workflows/tests.yml
deploy:
needs: tests
name: Deploy to pypi
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
# Sets up python3
- uses: actions/setup-python@v4
with:
python-version: 3.8
# Setup poetry
- name: Install poetry 1.8.4
run: |
python -m ensurepip
python -m pip install --upgrade pip
python -m pip install poetry==1.8.4
- name: Install build dependencies
run: sudo apt-get -y install libcairo2-dev pkg-config python3-dev
- name: Install dependencies
shell: bash
run: poetry install --all-extras
- name: Update version if needed
if: ${{ inputs.level != 'patch' }}
run: poetry version ${{ inputs.level }}
- name: Build package
run: poetry run python scripts/build_package.py ${{ inputs.core-repo }}
- name: Discover current version
run: |
poetry run pretext --version
echo "VERSION=$(poetry run pretext --version)" >> $GITHUB_ENV
- name: Publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build
- name: update changelog
run: |
poetry run python scripts/update_changelog.py
- name: Update version for next dev release
run: poetry version patch
- name: setup git config
run: |
# setup the username and email.
git config user.name "${{ github.actor }} via GitHub Actions"
git config user.email "${{ github.actor }}@github_actions.no_reply"
- name: commit version bump via pr
run: |
git checkout -b ${{ env.VERSION }}-deploy
git add CHANGELOG.md
git commit -m "update changelog for release"
git add pyproject.toml
git commit -m "bump version to next patch level for nightly releases"
git add pretext/resources/resource_hash_table.json
git commit --allow-empty -m "commit changes to resource_hash_table.json"
git push -f --set-upstream origin ${{ env.VERSION }}-deploy
gh pr create --fill
gh pr merge -s -d -t "Update changelog and bump version to next patch level for nightly releases"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ env.VERSION }}"
release_name: "v${{ env.VERSION }}"
body: |
See the [changelog](CHANGELOG.md) for details.
draft: false
prerelease: false
dispatch:
needs: deploy
strategy:
matrix:
repo: ['oscarlevin/pretext-docker', 'pretextbook/html-static']
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.PUSH_CODESPACES }}
repository: ${{ matrix.repo }}
event-type: pretext-publish
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'