|
| 1 | +name: "Release" |
| 2 | + |
| 3 | +# @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - v1* |
| 8 | + |
| 9 | +jobs: |
| 10 | + plugin: |
| 11 | + name: release-plugin |
| 12 | + runs-on: ubuntu-20.04 |
| 13 | + |
| 14 | + steps: |
| 15 | + ################################################################################################################## |
| 16 | + ################################################################################################################## |
| 17 | + ################################################################################################################## |
| 18 | + # Git checkout |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v2 |
| 21 | + |
| 22 | + # The github.ref is, for example, refs/tags/v5.0.145 or refs/tags/v5.0-r8 |
| 23 | + # Generate variables like: |
| 24 | + # SRS_TAG=v5.0-r8 |
| 25 | + # SRS_TAG=v5.0.145 |
| 26 | + # @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable |
| 27 | + - name: Generate varaiables |
| 28 | + run: | |
| 29 | + SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}') |
| 30 | + echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV |
| 31 | +
|
| 32 | + ################################################################################################################## |
| 33 | + ################################################################################################################## |
| 34 | + ################################################################################################################## |
| 35 | + # Create source tar for release. Note that it's for OpenWRT package srs-server, so the filename MUST be |
| 36 | + # srs-server-xxx.tar.gz, because the package is named srs-server. |
| 37 | + # Generate variables like: |
| 38 | + # SRS_SOURCE_TAR=SrsPlayer.zip |
| 39 | + # SRS_SOURCE_MD5=83e38700a80a26e30b2df054e69956e5 |
| 40 | + - name: Create source tar.gz |
| 41 | + run: | |
| 42 | + DEST_DIR=SrsPlayer && mkdir -p $DEST_DIR && |
| 43 | + zip -q -r ${DEST_DIR}.zip ${DEST_DIR} && du -sh ${DEST_DIR}* && |
| 44 | + echo "SRS_SOURCE_TAR=${DEST_DIR}.zip" >> $GITHUB_ENV && |
| 45 | + echo "SRS_SOURCE_MD5=$(md5sum ${DEST_DIR}.zip| awk '{print $1}')" >> $GITHUB_ENV |
| 46 | +
|
| 47 | + # Create release. |
| 48 | + - name: Create release |
| 49 | + id: create_release |
| 50 | + uses: actions/create-release@v1 |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + with: |
| 54 | + tag_name: ${{ github.ref }} |
| 55 | + release_name: Release ${{ github.ref }} |
| 56 | + body: | |
| 57 | + [${{ github.event.head_commit.message }}](https://github.com/ossrs/Typecho-Plugin-SrsPlayer/commit/${{ github.sha }}) |
| 58 | + ## Resource |
| 59 | + * Source: ${{ env.SRS_SOURCE_MD5 }} [${{ env.SRS_SOURCE_TAR }}](https://github.com/ossrs/Typecho-Plugin-SrsPlayer/releases/download/${{ env.SRS_TAG }}/${{ env.SRS_SOURCE_TAR }}) |
| 60 | + ## Doc |
| 61 | + * [Usage](https://github.com/ossrs/Typecho-Plugin-SrsPlayer/blob/${{ github.sha }}/README.md) |
| 62 | + draft: false |
| 63 | + prerelease: false |
| 64 | + |
| 65 | + # Upload release source files |
| 66 | + - name: Upload Release Assets Source |
| 67 | + id: upload-release-assets-source |
| 68 | + uses: dwenegar/upload-release-assets@v1 |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + with: |
| 72 | + release_id: ${{ steps.create_release.outputs.id }} |
| 73 | + assets_path: ${{ env.SRS_SOURCE_TAR }} |
0 commit comments