|
| 1 | +# TODO: consider updating requirements.txt for the documentation step, |
| 2 | +# as it does not work with python versions >3.8 |
| 3 | +# |
| 4 | +# NOTICE the generate-matrix and build are c/p from the build workflow |
| 5 | +# NOTICE manual deletion following a re-created tag and push will also trigger this |
| 6 | +# |
| 7 | +# Checks whether the pushed commit is buildable and creates a release with the provided tag. Only triggered on mega-* tag push |
| 8 | +# Documentation and distribution files (tools, readme, etc.) are uploaded as .zip files prepared similarly to the build_ESPEasy.sh |
| 9 | +# Every .bin build artifact is merged in a single .zip file, which is then uploaded as a single release asset |
| 10 | + |
| 11 | +name: Release |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches-ignore: '**' |
| 16 | + tags: 'mega-*' |
| 17 | + |
| 18 | +jobs: |
| 19 | + generate-matrix: |
| 20 | + runs-on: ubuntu-20.04 |
| 21 | + outputs: |
| 22 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v2 |
| 25 | + - uses: actions/setup-python@v2 |
| 26 | + with: |
| 27 | + python-version: '3.8' |
| 28 | + - id: set-matrix |
| 29 | + run: | |
| 30 | + pip install platformio |
| 31 | + python tools/ci/generate-matrix.py |
| 32 | +
|
| 33 | + build: |
| 34 | + needs: generate-matrix |
| 35 | + runs-on: ubuntu-20.04 |
| 36 | + strategy: |
| 37 | + matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v2 |
| 40 | + - uses: actions/setup-python@v2 |
| 41 | + with: |
| 42 | + python-version: '3.8' |
| 43 | + - uses: actions/cache@v2 |
| 44 | + with: |
| 45 | + path: ~/.cache/pip |
| 46 | + key: ${{ runner.os }}-${{ hashFiles('requirements.txt') }} |
| 47 | + - uses: actions/cache@v2 |
| 48 | + if: ${{ contains(matrix.env, 'esp32') }} |
| 49 | + with: |
| 50 | + path: ~/.platformio |
| 51 | + key: ${{ runner.os }}-esp32-${{ hashFiles('platformio*.ini') }} |
| 52 | + - uses: actions/cache@v2 |
| 53 | + if: ${{ contains(matrix.env, 'esp8266') }} |
| 54 | + with: |
| 55 | + path: ~/.platformio |
| 56 | + key: ${{ runner.os }}-esp8266-${{ hashFiles('platformio*.ini') }} |
| 57 | + - name: Dependencies |
| 58 | + run: | |
| 59 | + sudo apt install binutils |
| 60 | + pip install -r requirements.txt |
| 61 | + platformio update |
| 62 | + - name: Build and archive |
| 63 | + id: build-and-archive |
| 64 | + env: |
| 65 | + CHIP: ${{ matrix.chip }} |
| 66 | + ENV: ${{ matrix.env }} |
| 67 | + run: | |
| 68 | + python tools/ci/build-and-archive.py |
| 69 | + - uses: actions/upload-artifact@v2 |
| 70 | + with: |
| 71 | + name: Binaries |
| 72 | + path: ESPEasy_${{ matrix.env }}.zip |
| 73 | + if-no-files-found: ignore |
| 74 | + |
| 75 | + prepare-dist: |
| 76 | + needs: build |
| 77 | + runs-on: ubuntu-20.04 |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v2 |
| 80 | + - uses: actions/setup-python@v2 |
| 81 | + with: |
| 82 | + python-version: '3.8' |
| 83 | + - uses: actions/cache@v2 |
| 84 | + with: |
| 85 | + path: ~/.cache/pip |
| 86 | + key: ${{ runner.os }}-docs-${{ hashFiles('requirements.txt') }} |
| 87 | + - name: Build documentation |
| 88 | + run: | |
| 89 | + cd docs |
| 90 | + sudo apt install imagemagick zip |
| 91 | + pip install -r requirements.txt |
| 92 | + make html |
| 93 | + cd .. |
| 94 | + zip -r -qq ESPEasy_docs.zip docs/build/* |
| 95 | + - name: Package utilities |
| 96 | + run: | |
| 97 | + cd dist |
| 98 | + zip -r -qq ../ESPEasy_dist.zip * |
| 99 | + cd .. |
| 100 | + - uses: actions/upload-artifact@v2 |
| 101 | + with: |
| 102 | + name: Distribution |
| 103 | + path: | |
| 104 | + ESPEasy_docs.zip |
| 105 | + ESPEasy_dist.zip |
| 106 | +
|
| 107 | + prepare-notes: |
| 108 | + needs: build |
| 109 | + runs-on: ubuntu-20.04 |
| 110 | + outputs: |
| 111 | + notes: ${{ steps.release-notes.outputs.result }} |
| 112 | + steps: |
| 113 | + - id: release-notes |
| 114 | + uses: actions/github-script@v4 |
| 115 | + with: |
| 116 | + result-encoding: string |
| 117 | + script: | |
| 118 | + const tagRefObj = await github.git.getRef({ |
| 119 | + ...context.repo, |
| 120 | + ref: context.ref.replace('refs/', '') |
| 121 | + }); |
| 122 | +
|
| 123 | + const tagObj = await github.git.getTag({ |
| 124 | + ...context.repo, |
| 125 | + tag_sha: tagRefObj.data.object.sha |
| 126 | + }); |
| 127 | +
|
| 128 | + return tagObj.data.message; |
| 129 | +
|
| 130 | + release: |
| 131 | + needs: [build, prepare-dist, prepare-notes] |
| 132 | + runs-on: ubuntu-20.04 |
| 133 | + steps: |
| 134 | + - uses: actions/setup-python@v2 |
| 135 | + with: |
| 136 | + python-version: '3.8' |
| 137 | + - uses: actions/download-artifact@v2 |
| 138 | + with: |
| 139 | + path: artifacts/ |
| 140 | + - run: | |
| 141 | + ls -R |
| 142 | + sudo apt install zipmerge |
| 143 | + zipmerge ESPEasy_binaries.zip artifacts/Binaries/*.zip |
| 144 | + - uses: ncipollo/release-action@v1 |
| 145 | + with: |
| 146 | + artifacts: "ESPEasy_binaries.zip,artifacts/Distribution/*.zip" |
| 147 | + body: ${{ needs.prepare-notes.outputs.notes }} |
| 148 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments