|
| 1 | +# Based on https://github.com/im85288/service.upnext/blob/master/.github/workflows/release.yml |
| 2 | +name: Make Release |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + - '*-dev' |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + if: github.repository == 'anxdpanic/script.module.python.twitch' |
| 12 | + |
| 13 | + name: Make Release |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Release Status |
| 18 | + id: release |
| 19 | + run: | |
| 20 | + version=${GITHUB_REF/refs\/tags\//} |
| 21 | + if [[ $version == *-dev ]] ; |
| 22 | + then |
| 23 | + echo ::set-output name=pre-release::true |
| 24 | + else |
| 25 | + echo ::set-output name=pre-release::false |
| 26 | + fi |
| 27 | +
|
| 28 | + - name: Checkout Add-on |
| 29 | + uses: actions/checkout@v2 |
| 30 | + with: |
| 31 | + path: ${{ github.event.repository.name }} |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + run: | |
| 35 | + sudo apt-get install libxml2-utils xmlstarlet zip |
| 36 | +
|
| 37 | + - name: Get Changelog |
| 38 | + id: changelog |
| 39 | + run: | |
| 40 | + changes=$(xmlstarlet sel -t -v '//news' -n addon.xml) |
| 41 | + changes="${changes//'%'/'%25'}" |
| 42 | + changes="${changes//$'\n'/'%0A'}" |
| 43 | + changes="${changes//$'\r'/'%0D'}" |
| 44 | + echo ::set-output name=changes::$changes |
| 45 | + working-directory: ${{ github.event.repository.name }} |
| 46 | + |
| 47 | + - name: Remove Unwanted Files |
| 48 | + run: | |
| 49 | + mv .git .. |
| 50 | + rm -rf .??* |
| 51 | + rm *.md |
| 52 | +
|
| 53 | + - name: Create Zip (Isengard) |
| 54 | + id: zip-isengard |
| 55 | + run: | |
| 56 | + version=$(xmlstarlet sel -t -v 'string(/addon/@version)' addon.xml) |
| 57 | + filename=${{ github.event.repository.name }}-${version}.zip |
| 58 | + cd .. |
| 59 | + zip -r $filename ${{ github.event.repository.name }} |
| 60 | + echo ::set-output name=filename::$filename |
| 61 | + working-directory: ${{ github.event.repository.name }} |
| 62 | + |
| 63 | + - name: Create Zip (Matrix) |
| 64 | + id: zip-matrix |
| 65 | + run: | |
| 66 | + xmlstarlet ed -L -u '//import[@addon="xbmc.python"]/@version' -v "3.0.0" addon.xml |
| 67 | + version=$(xmlstarlet sel -t -v 'string(/addon/@version)' addon.xml) |
| 68 | + xmlstarlet ed -L -u '/addon/@version' -v "${version}+matrix.1" addon.xml |
| 69 | + version=$(xmlstarlet sel -t -v 'string(/addon/@version)' addon.xml) |
| 70 | + filename=${{ github.event.repository.name }}-${version}.zip |
| 71 | + cd .. |
| 72 | + zip -r $filename ${{ github.event.repository.name }} |
| 73 | + mv .git ${{ github.event.repository.name }} |
| 74 | + echo ::set-output name=filename::$filename |
| 75 | + working-directory: ${{ github.event.repository.name }} |
| 76 | + |
| 77 | + - name: Create Release |
| 78 | + id: create-release |
| 79 | + uses: actions/create-release@v1 |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + with: |
| 83 | + tag_name: ${{ github.ref }} |
| 84 | + release_name: ${{ github.ref }} |
| 85 | + body: ${{ steps.changelog.outputs.changes }} |
| 86 | + draft: false |
| 87 | + prerelease: ${{ steps.release.outputs.pre-release }} |
| 88 | + |
| 89 | + - name: Upload Zip (Isengard) |
| 90 | + id: upload-isengard |
| 91 | + uses: actions/upload-release-asset@v1 |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + with: |
| 95 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 96 | + asset_name: ${{ steps.zip-isengard.outputs.filename }} |
| 97 | + asset_path: ${{ steps.zip-isengard.outputs.filename }} |
| 98 | + asset_content_type: application/zip |
| 99 | + |
| 100 | + - name: Upload Zip (Matrix) |
| 101 | + id: upload-matrix |
| 102 | + uses: actions/upload-release-asset@v1 |
| 103 | + env: |
| 104 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + with: |
| 106 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 107 | + asset_name: ${{ steps.zip-matrix.outputs.filename }} |
| 108 | + asset_path: ${{ steps.zip-matrix.outputs.filename }} |
| 109 | + asset_content_type: application/zip |
0 commit comments