Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 1 | name: Publish |
| 2 | on: |
| 3 | push: |
| 4 | branches: |
| 5 | - master |
| 6 | paths-ignore: |
| 7 | - '.mailmap' |
| 8 | - 'README.md' |
| 9 | workflow_dispatch: |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 10 | inputs: |
| 11 | skip-deploy: |
| 12 | description: 'Skip deployment?' |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 13 | type: boolean |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 14 | |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 15 | permissions: {} |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 16 | |
Davide Pesavento | e857469 | 2023-02-16 16:20:22 -0500 | [diff] [blame] | 17 | env: |
| 18 | SPHINXOPTS: --color |
| 19 | |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 20 | jobs: |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 21 | html: |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 22 | runs-on: ubuntu-latest |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 23 | outputs: |
| 24 | version: ${{ steps.version.outputs.version }} |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 25 | steps: |
Davide Pesavento | e857469 | 2023-02-16 16:20:22 -0500 | [diff] [blame] | 26 | - name: Checkout repository |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 27 | uses: actions/checkout@v3 |
| 28 | - name: Extract version |
| 29 | id: version |
| 30 | run: | |
| 31 | v=$(sed -nE "s/^version\s*=\s*['\"]([0-9]+(\.[0-9]+){0,3})['\"]/\1/p" conf.py) |
| 32 | if [[ -z $v ]]; then |
| 33 | echo "::error::Could not find a valid version in conf.py" |
| 34 | exit 1 |
| 35 | fi |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 36 | echo "version=$v" >> $GITHUB_OUTPUT |
| 37 | - name: Set up Python |
| 38 | uses: actions/setup-python@v4 |
| 39 | with: |
Davide Pesavento | c73673d | 2023-02-16 16:34:11 -0500 | [diff] [blame] | 40 | python-version: '3.11' |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 41 | - name: Install dependencies |
| 42 | run: | |
| 43 | python -m pip install --upgrade pip |
Davide Pesavento | c73673d | 2023-02-16 16:34:11 -0500 | [diff] [blame] | 44 | python -m pip install -r requirements.txt |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 45 | - name: Generate HTML pages |
Davide Pesavento | e857469 | 2023-02-16 16:20:22 -0500 | [diff] [blame] | 46 | run: | |
| 47 | export SOURCE_DATE_EPOCH="$(git log -1 --format=%ct)" |
| 48 | make html |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 49 | - name: Publish HTML pages |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 50 | uses: actions/upload-artifact@v3 |
Davide Pesavento | 6b2bb62 | 2023-01-12 22:00:44 -0500 | [diff] [blame] | 51 | with: |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 52 | name: ndn-packet-spec-html |
| 53 | path: _build/html |
| 54 | if-no-files-found: error |
Davide Pesavento | 16c9fd2 | 2023-01-17 22:08:10 -0500 | [diff] [blame] | 55 | |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 56 | pdf: |
Davide Pesavento | 16c9fd2 | 2023-01-17 22:08:10 -0500 | [diff] [blame] | 57 | runs-on: ubuntu-latest |
| 58 | steps: |
Davide Pesavento | e857469 | 2023-02-16 16:20:22 -0500 | [diff] [blame] | 59 | - name: Checkout repository |
Davide Pesavento | 16c9fd2 | 2023-01-17 22:08:10 -0500 | [diff] [blame] | 60 | uses: actions/checkout@v3 |
| 61 | - name: Set up Python |
| 62 | uses: actions/setup-python@v4 |
| 63 | with: |
Davide Pesavento | c73673d | 2023-02-16 16:34:11 -0500 | [diff] [blame] | 64 | python-version: '3.11' |
Davide Pesavento | 16c9fd2 | 2023-01-17 22:08:10 -0500 | [diff] [blame] | 65 | - name: Install dependencies |
| 66 | run: | |
| 67 | sudo apt-get -qq update |
| 68 | sudo apt-get -qy install --no-install-recommends latexmk \ |
| 69 | texlive-latex-extra texlive-fonts-recommended tex-gyre |
| 70 | python -m pip install --upgrade pip |
Davide Pesavento | c73673d | 2023-02-16 16:34:11 -0500 | [diff] [blame] | 71 | python -m pip install -r requirements.txt |
Davide Pesavento | 16c9fd2 | 2023-01-17 22:08:10 -0500 | [diff] [blame] | 72 | - name: Generate PDF document |
Davide Pesavento | e857469 | 2023-02-16 16:20:22 -0500 | [diff] [blame] | 73 | run: | |
| 74 | export SOURCE_DATE_EPOCH="$(git log -1 --format=%ct)" |
| 75 | make latexpdf |
Davide Pesavento | 16c9fd2 | 2023-01-17 22:08:10 -0500 | [diff] [blame] | 76 | - name: Publish PDF document |
| 77 | uses: actions/upload-artifact@v3 |
| 78 | with: |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 79 | name: ndn-packet-spec-pdf |
Davide Pesavento | 16c9fd2 | 2023-01-17 22:08:10 -0500 | [diff] [blame] | 80 | path: _build/latex/ndn-packet-spec.pdf |
| 81 | if-no-files-found: error |
Davide Pesavento | c0bab4e | 2023-02-03 18:20:25 -0500 | [diff] [blame] | 82 | |
| 83 | deploy: |
| 84 | if: github.ref_name == 'master' && !inputs.skip-deploy |
| 85 | needs: html |
| 86 | uses: named-data/actions/.github/workflows/docs-deployment.yml@v1 |
| 87 | with: |
| 88 | artifact-name: ndn-packet-spec-html |
| 89 | version: ${{ needs.html.outputs.version }} |
| 90 | secrets: inherit |