|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: "Tag / Release name (leave empty for dry-run)" |
| 8 | + required: false |
| 9 | + |
| 10 | +env: |
| 11 | + pyinstaller-version: "4.0" |
| 12 | + name: modimporter |
| 13 | + artifacts-content-type: application/zip |
| 14 | + |
| 15 | +jobs: |
| 16 | + tag-and-release: |
| 17 | + name: Tag and create release |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + upload_url: ${{ steps.release.outputs.upload_url }} |
| 21 | + steps: |
| 22 | + - name: Checkout files |
| 23 | + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f |
| 24 | + |
| 25 | + - name: Tag |
| 26 | + if: github.event.inputs.tag |
| 27 | + run: | |
| 28 | + git tag ${{ github.event.inputs.tag }} |
| 29 | + git push origin --tags |
| 30 | +
|
| 31 | + - name: Create release |
| 32 | + if: github.event.inputs.tag |
| 33 | + id: release |
| 34 | + uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e |
| 35 | + with: |
| 36 | + release_name: ${{ github.event.inputs.tag }} |
| 37 | + tag_name: ${{ github.event.inputs.tag }} |
| 38 | + body_path: ${{ env.release-notes }} |
| 39 | + commitish: main |
| 40 | + env: |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + archive-and-upload-python-artifacts: |
| 44 | + name: Archive and upload Python artifacts |
| 45 | + needs: tag-and-release |
| 46 | + runs-on: ubuntu-latest |
| 47 | + env: |
| 48 | + artifacts-python: modimporter-python.zip |
| 49 | + license: LICENSE |
| 50 | + readme: README.md |
| 51 | + sjson: sjson |
| 52 | + steps: |
| 53 | + - name: Checkout files |
| 54 | + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f |
| 55 | + with: |
| 56 | + ref: ${{ github.event.inputs.tag || github.sha }} |
| 57 | + submodules: true |
| 58 | + |
| 59 | + - name: Consolidate Python artifacts in a zip |
| 60 | + run: | |
| 61 | + rm -r ${{ env.sjson }}/.git |
| 62 | + zip ${{ env.artifacts-python }} -r ${{ env.name }}.py ${{ env.sjson }} ${{ env.license }} ${{ env.readme }} |
| 63 | +
|
| 64 | + - name: Upload artifacts to workflow |
| 65 | + uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074 |
| 66 | + with: |
| 67 | + name: ${{ env.artifacts-python }} |
| 68 | + path: ${{ env.artifacts-python }} |
| 69 | + retention-days: 1 |
| 70 | + |
| 71 | + - name: Upload artifacts to release |
| 72 | + if: needs.tag-and-release.outputs.upload_url |
| 73 | + uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 |
| 74 | + with: |
| 75 | + upload_url: ${{ needs.tag-and-release.outputs.upload_url }} |
| 76 | + asset_path: ${{ env.artifacts-python }} |
| 77 | + asset_name: ${{ env.artifacts-python }} |
| 78 | + asset_content_type: ${{ env.artifacts-content-type }} |
| 79 | + env: |
| 80 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + |
| 82 | + build-and-upload-binaries: |
| 83 | + name: Build and upload binaries |
| 84 | + needs: tag-and-release |
| 85 | + runs-on: ${{ matrix.os }} |
| 86 | + strategy: |
| 87 | + matrix: |
| 88 | + os: [windows-latest, macos-latest, ubuntu-latest] |
| 89 | + include: |
| 90 | + - os: windows-latest |
| 91 | + pip-cache-path: ~\AppData\Local\pip\Cache |
| 92 | + artifacts: modimporter-windows.zip |
| 93 | + - os: macos-latest |
| 94 | + pip-cache-path: ~/Library/Caches/pip |
| 95 | + artifacts: modimporter-macos.zip |
| 96 | + - os: ubuntu-latest |
| 97 | + pip-cache-path: ~/.cache/pip |
| 98 | + artifacts: modimporter-linux.zip |
| 99 | + steps: |
| 100 | + - name: Checkout files |
| 101 | + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f |
| 102 | + with: |
| 103 | + ref: ${{ github.event.inputs.tag || github.sha }} |
| 104 | + submodules: true |
| 105 | + |
| 106 | + - name: Set up Python |
| 107 | + uses: actions/setup-python@dc73133d4da04e56a135ae2246682783cc7c7cb6 |
| 108 | + with: |
| 109 | + python-version: 3.9 |
| 110 | + |
| 111 | + - name: Retrieve pip dependencies from cache |
| 112 | + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 |
| 113 | + with: |
| 114 | + path: | |
| 115 | + ${{ env.pythonLocation }}\lib\site-packages |
| 116 | + ${{ matrix.pip-cache-path }} |
| 117 | + key: ${{ runner.os }}-pip-cache-${{ env.pyinstaller-version }} |
| 118 | + |
| 119 | + - name: Install pip dependencies |
| 120 | + run: python -m pip install pyinstaller==${{ env.pyinstaller-version }} |
| 121 | + |
| 122 | + - name: Build binaries with PyInstaller |
| 123 | + run: python -m PyInstaller --onefile ${{ env.name }}.py --name ${{ env.name }} |
| 124 | + |
| 125 | + - name: Consolidate artifacts in a zip |
| 126 | + if: startsWith(runner.os, 'Windows') |
| 127 | + run: Compress-Archive dist/${{ env.name }}.exe ${{ matrix.artifacts }} |
| 128 | + |
| 129 | + - name: Consolidate artifacts in a zip |
| 130 | + if: startsWith(runner.os, 'macOS') || startsWith(runner.os, 'Linux') |
| 131 | + run: | |
| 132 | + mv dist/${{ env.name }} . |
| 133 | + zip ${{ matrix.artifacts }} -r ${{ env.name }} |
| 134 | +
|
| 135 | + - name: Upload artifacts to workflow |
| 136 | + uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074 |
| 137 | + with: |
| 138 | + name: ${{ matrix.artifacts }} |
| 139 | + path: ${{ matrix.artifacts }} |
| 140 | + retention-days: 1 |
| 141 | + |
| 142 | + - name: Upload artifacts to release |
| 143 | + if: needs.tag-and-release.outputs.upload_url |
| 144 | + uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 |
| 145 | + with: |
| 146 | + upload_url: ${{ needs.tag-and-release.outputs.upload_url }} |
| 147 | + asset_path: ${{ matrix.artifacts }} |
| 148 | + asset_name: ${{ matrix.artifacts }} |
| 149 | + asset_content_type: ${{ env.artifacts-content-type }} |
| 150 | + env: |
| 151 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments