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