CI: add snap.yml #3369
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Author: Kang Lin<kl222@126.com> | |
| # workflow syntax: https://docs.github.com/actions/writing-workflows/workflow-syntax-for-github-actions | |
| name: build | |
| env: | |
| artifact_path: artifact_path | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RabbitRemoteControl_VERSION: v0.0.36 | |
| RabbitRemoteControl_VERSION_PRE: v0.0.35 | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| ubuntu: | |
| uses: ./.github/workflows/ubuntu.yml | |
| secrets: inherit | |
| if: false | |
| aarch64: | |
| uses: ./.github/workflows/aarch64.yml | |
| secrets: inherit | |
| if: false | |
| appimage: | |
| uses: ./.github/workflows/appimage.yml | |
| secrets: inherit | |
| if: false | |
| linux: | |
| uses: ./.github/workflows/linux.yml | |
| secrets: inherit | |
| flatpak: | |
| uses: ./.github/workflows/flatpak.yml | |
| secrets: inherit | |
| docker: | |
| uses: ./.github/workflows/docker.yml | |
| secrets: inherit | |
| msvc: | |
| uses: ./.github/workflows/msvc.yml | |
| secrets: inherit | |
| mingw: | |
| uses: ./.github/workflows/mingw.yml | |
| secrets: inherit | |
| macos: | |
| uses: ./.github/workflows/macos.yml | |
| secrets: inherit | |
| android: | |
| uses: ./.github/workflows/android.yml | |
| secrets: inherit | |
| doxygen: | |
| uses: ./.github/workflows/doxygen.yml | |
| secrets: inherit | |
| deploy: | |
| #if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| runs-on: ubuntu-latest | |
| needs: [linux, docker, flatpak, msvc, doxygen, android, macos] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| submodules: false | |
| - name: clean test tag | |
| if: ${{ startsWith(github.ref, 'refs/heads/master') }} | |
| continue-on-error: true | |
| run: | | |
| gh release delete test_${{ github.ref_name }} -y --cleanup-tag | |
| - name: Download ubuntu | |
| uses: actions/download-artifact@v4 | |
| if: false | |
| with: | |
| pattern: ${{ needs.ubuntu.outputs.name }}* | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download appimage | |
| uses: actions/download-artifact@v4 | |
| if: false | |
| with: | |
| pattern: ${{ needs.appimage.outputs.name }}* | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download linux | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ needs.linux.outputs.name }}* | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download docker | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ needs.docker.outputs.name }}* | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download flatpak | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ needs.flatpak.outputs.name }}* | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download msvc | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ needs.msvc.outputs.name }}* | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download mingw | |
| if: false | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.mingw.outputs.name }} | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download macos | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ needs.macos.outputs.name }}* | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download android | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ needs.android.outputs.name }}* | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Download doxygen | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.doxygen.outputs.name }} | |
| path: ${{ env.artifact_path }} | |
| merge-multiple: true | |
| - name: Process configure file | |
| run: | | |
| git clone https://github.com/KangLin/RabbitCommon.git | |
| ./RabbitCommon/Install/MergeJsonFile.sh \ | |
| "${{ github.workspace }}/update.json" \ | |
| "${{ env.artifact_path }}" "${{ env.artifact_path }}/version.json" | |
| rm ${{ env.artifact_path }}/*.json | |
| - name: Add change log file in Release.md file | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| run: | | |
| # 因为其它网站也可能需要,所以用完整的 URL | |
| echo "|:us: English|:cn: 中文|" >> ${{github.workspace}}/Release.md | |
| echo "| :- |:- |" >> ${{github.workspace}}/Release.md | |
| echo "|[Change log](https://github.com/KangLin/RabbitRemoteControl/blob/${{env.RabbitRemoteControl_VERSION}}/ChangeLog.md)|[修改日志](https://github.com/KangLin/RabbitRemoteControl/blob/${{env.RabbitRemoteControl_VERSION}}/ChangeLog_zh_CN.md)|" >> ${{github.workspace}}/Release.md | |
| echo "|Full Change: [${{env.RabbitRemoteControl_VERSION_PRE}}...${{env.RabbitRemoteControl_VERSION}}](https://github.com/KangLin/RabbitRemoteControl/compare/${{env.RabbitRemoteControl_VERSION_PRE}}...${{env.RabbitRemoteControl_VERSION}})|全部修改: [${{env.RabbitRemoteControl_VERSION_PRE}}...${{env.RabbitRemoteControl_VERSION}}](https://github.com/KangLin/RabbitRemoteControl/compare/${{env.RabbitRemoteControl_VERSION_PRE}}...${{env.RabbitRemoteControl_VERSION}})|" >> ${{github.workspace}}/Release.md | |
| BUILD_TIME=`date --rfc-3339=second` | |
| echo "|Build time: $BUILD_TIME|构建时间:$BUILD_TIME|" >> ${{github.workspace}}/Release.md | |
| echo "|[Installation package description](https://github.com/KangLin/RabbitRemoteControl/blob/${{env.RabbitRemoteControl_VERSION}}/README.md#Installation-package-description)|[安装包说明](https://github.com/KangLin/RabbitRemoteControl/blob/${{env.RabbitRemoteControl_VERSION}}/README_zh_CN.md#安装包说明)|" >> ${{github.workspace}}/Release.md | |
| echo "" >> ${{github.workspace}}/Release.md | |
| - name: Add test comment in Release.md file | |
| if: ${{ ! startsWith(github.ref, 'refs/tags/') }} | |
| run: | | |
| echo "**This release is for development and testing purposes only!**" >> ${{github.workspace}}/Release.md | |
| echo "" >> ${{github.workspace}}/Release.md | |
| echo "Commit: [${{github.sha}}](https://github.com/KangLin/RabbitRemoteControl/commit/${{github.sha}})" >> ${{github.workspace}}/Release.md | |
| echo "" >> ${{github.workspace}}/Release.md | |
| echo "Build time: `date --rfc-3339=second`" >> ${{github.workspace}}/Release.md | |
| echo "" >> ${{github.workspace}}/Release.md | |
| echo "[:us: Change log](https://github.com/KangLin/RabbitRemoteControl/blob/test_${{ github.ref_name }}/ChangeLog.md)" >> ${{github.workspace}}/Release.md | |
| echo "" >> ${{github.workspace}}/Release.md | |
| echo "[Installation package description](https://github.com/KangLin/RabbitRemoteControl/blob/test_${{ github.ref_name }}/README.md#Installation-package-description)" >> ${{github.workspace}}/Release.md | |
| - name: Add artifact sha256sum in Release.md file | |
| run: | | |
| echo "" >> ${{github.workspace}}/Release.md | |
| echo "File checksum:" >> ${{github.workspace}}/Release.md | |
| echo "" >> ${{github.workspace}}/Release.md | |
| echo "|File|Checksum(sha256)|Checksum(md5)" >> ${{github.workspace}}/Release.md | |
| echo "| :- | :- |:-|" >> ${{github.workspace}}/Release.md | |
| cd ${{ env.artifact_path }} | |
| for file in * | |
| do | |
| echo "$file" | |
| if [ -f $file ]; then | |
| if [ "${file##*.}" != "xml" ] && [ "${file##*.}" != "json" ]; then | |
| Sum256=`sha256sum $file | awk '{print "|", $2, "|", $1, "|"}'` | |
| SumMd5=`md5sum $file | awk '{print $1, "|"}'` | |
| echo "${Sum256}${SumMd5}" >> ${{github.workspace}}/Release.md | |
| fi | |
| else | |
| rm -fr $file | |
| fi | |
| done | |
| echo "" >> ${{github.workspace}}/Release.md | |
| - name: Add snap donwload in Release.md file | |
| run: | | |
| echo "" >> ${{github.workspace}}/Release.md | |
| echo "[](https://flathub.org/apps/io.github.KangLin.RabbitRemoteControl)" >> ${{github.workspace}}/Release.md | |
| echo "" >> ${{github.workspace}}/Release.md | |
| echo "[](https://snapcraft.io/rabbitremotecontrol)" >> ${{github.workspace}}/Release.md | |
| echo "[](https://snapcraft.io/rabbitremotecontrol)" >> ${{github.workspace}}/Release.md | |
| # See: [访问有关工作流运行的上下文信息](https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context) | |
| - name: Create Github Release | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| continue-on-error: true | |
| run: | | |
| gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --notes-file ${{github.workspace}}/Release.md | |
| - name: Upload To Github Release | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| run: | | |
| gh release upload ${{ github.ref_name }} ${{github.workspace}}/${{ env.artifact_path }}/* ${{github.workspace}}/update.json ${{github.workspace}}/Release.md | |
| - name: Upload test tag To Github Release | |
| if: ${{ startsWith(github.ref, 'refs/heads/master') }} | |
| run: | | |
| gh release create test_${{ github.ref_name }} --prerelease --latest=false --title "Recently developed build - ${{ github.ref_name }}" --notes-file ${{github.workspace}}/Release.md | |
| gh release upload test_${{ github.ref_name }} --clobber ${{github.workspace}}/${{ env.artifact_path }}/* ${{github.workspace}}/update.json ${{github.workspace}}/Release.md |