|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +env: |
| 7 | + release: Release |
| 8 | + os: ubuntu-latest |
| 9 | + vroom: 1.12.0 |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + name: Release |
| 14 | + # disbale action, we need discussions on https://github.com/pgRouting/pgorpy/ |
| 15 | + if: ${{ false }} |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Initialize mandatory git config |
| 27 | + run: | |
| 28 | + git config user.name "github-actions[bot]" |
| 29 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 30 | +
|
| 31 | + - name: Get postgres version |
| 32 | + run: | |
| 33 | + sudo service postgresql start |
| 34 | + PGVER=$(psql --version | grep -Po '(?<=psql \(PostgreSQL\) )[^;]+(?=\.\d+ \()') |
| 35 | + echo "PGVER=${PGVER}" >> $GITHUB_ENV |
| 36 | + echo "PGPORT=5432" >> $GITHUB_ENV |
| 37 | + PROJECT_VERSION=$(grep -Po '(?<=project\(pgORpy VERSION )[^;]+' CMakeLists.txt) |
| 38 | + echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV |
| 39 | + echo "TAG_NAME=v${PROJECT_VERSION}" >> $GITHUB_ENV |
| 40 | +
|
| 41 | + - name: Create and Push Tag |
| 42 | + run: | |
| 43 | + git tag -a "${TAG_NAME}" -m "Release version ${TAG_NAME}" |
| 44 | + git push origin "${TAG_NAME}" |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + |
| 48 | + - name: Install python |
| 49 | + uses: actions/setup-python@v5 |
| 50 | + with: |
| 51 | + python-version: '3.12' |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + run: | |
| 55 | + sudo apt-get update |
| 56 | +
|
| 57 | + # Basic dependencies |
| 58 | + sudo apt-get install -y \ |
| 59 | + postgresql-${PGVER} \ |
| 60 | + postgresql-server-dev-${PGVER} |
| 61 | +
|
| 62 | + # documentation dependencies |
| 63 | + sudo apt-get install -y \ |
| 64 | + graphviz \ |
| 65 | + python3-sphinx \ |
| 66 | + python3-sphinx-bootstrap-theme |
| 67 | +
|
| 68 | + - name: Install Google OR-Tools |
| 69 | + run: | |
| 70 | + sudo pip install --root=/ ortools==9.10.4067 |
| 71 | +
|
| 72 | + - name: Configure |
| 73 | + run: | |
| 74 | + mkdir build |
| 75 | + cd build |
| 76 | + cmake -DCMAKE_BUILD_TYPE=${{ env.release }} .. |
| 77 | +
|
| 78 | + - name: Build |
| 79 | + run: | |
| 80 | + cd build |
| 81 | + make doc |
| 82 | +
|
| 83 | + - name: Update Users Documentation |
| 84 | + run: | |
| 85 | + git checkout origin/gh-pages |
| 86 | + git checkout -b gh-pages |
| 87 | + PROJECT_MAJOR="v${PROJECT_VERSION%%.*}" |
| 88 | + rm -rf ${PROJECT_MAJOR} |
| 89 | + cp -r build/doc/_build ${PROJECT_MAJOR} |
| 90 | + git add ${PROJECT_MAJOR} |
| 91 | + git diff-index --quiet HEAD || git commit -m "Update users documentation for ${PROJECT_VERSION} (tag ${TAG_NAME})" |
| 92 | + git fetch origin |
| 93 | + git rebase origin/gh-pages |
| 94 | + git push origin gh-pages |
| 95 | + git checkout @{-2} |
| 96 | +
|
| 97 | + - name: Download Assets |
| 98 | + run: | |
| 99 | + wget -c https://github.com/${{ github.repository }}/archive/${TAG_NAME}.zip |
| 100 | + wget -c https://github.com/${{ github.repository }}/archive/${TAG_NAME}.tar.gz |
| 101 | + mv ${TAG_NAME}.zip ${{ github.event.repository.name }}-${PROJECT_VERSION}.zip |
| 102 | + mv ${TAG_NAME}.tar.gz ${{ github.event.repository.name }}-${PROJECT_VERSION}.tar.gz |
| 103 | +
|
| 104 | + - name: Make Attachments |
| 105 | + run: | |
| 106 | + cd build/doc/_build |
| 107 | +
|
| 108 | + cp -r html doc-v${PROJECT_VERSION}-en |
| 109 | + rm -rf doc-v${PROJECT_VERSION}-en/es |
| 110 | + tar -zcvf doc-v${PROJECT_VERSION}-en.tar.gz doc-v${PROJECT_VERSION}-en |
| 111 | +
|
| 112 | + cd ../.. |
| 113 | + cat NEWS.md | tr '\0' '\n' > release_body.txt |
| 114 | +
|
| 115 | + # Only executed during the first release |
| 116 | + grep -q '[^[:space:]]' < release_body.txt || cp NEWS.md release_body.txt |
| 117 | +
|
| 118 | + echo >> release_body.txt |
| 119 | + echo "**Attachments**" >> release_body.txt |
| 120 | + echo "File | Contents" >> release_body.txt |
| 121 | + echo "| --- | --- |" >> release_body.txt |
| 122 | + echo "| \`doc-v${PROJECT_VERSION}-en.tar.gz\` | English documentation. Redirection to English" >> release_body.txt |
| 123 | + echo "| \`pgorpy-${PROJECT_VERSION}.tar.gz\` | tar.gz of the release" >> release_body.txt |
| 124 | + echo "| \`pgorpy-${PROJECT_VERSION}.zip\` | zip of the release" >> release_body.txt |
| 125 | + cat release_body.txt |
| 126 | +
|
| 127 | + - name: Create Draft Release |
| 128 | + uses: softprops/action-gh-release@v1 |
| 129 | + with: |
| 130 | + body_path: release_body.txt |
| 131 | + name: ${{ env.TAG_NAME }} |
| 132 | + draft: true |
| 133 | + prerelease: false |
| 134 | + files: | |
| 135 | + build/doc/doc-v${{ env.PROJECT_VERSION }}-en.tar.gz |
| 136 | + ${{ github.event.repository.name }}-${{ env.PROJECT_VERSION }}.zip |
| 137 | + ${{ github.event.repository.name }}-${{ env.PROJECT_VERSION }}.tar.gz |
| 138 | +
|
| 139 | + env: |
| 140 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments