From 6b3058adbd35f9e1a52843fa716ab995658cecfc Mon Sep 17 00:00:00 2001 From: Markson Date: Sat, 17 Jun 2023 11:27:55 +0800 Subject: [PATCH 1/2] build.yml: fix upload packages to releases chore: upgrade dae-wing (#41) ci: add a workflow to synchronize upstream repositories (#43) * ci: add a workflow to synchronize upstream dae-wing with workflow_dispatch * ci(sync): fix sync commit message * ci(sync): change name to Synchronize upstream Co-authored-by: Kevin Yu <31861128+yqlbu@users.noreply.github.com> * ci(sync): rename sync.yml to sync-upstream-source.yml * ci(sync): change name to Synchronize Upstream --------- Co-authored-by: Kevin Yu <31861128+yqlbu@users.noreply.github.com> ci(sync): input variables should be retrived from inputs ci(sync): should clone full history with fetch-depth: 0 ci(build.yml): fix upload to release --- .github/workflows/build.yml | 141 ++++++++++----------- .github/workflows/sync-upstream-source.yml | 12 +- install/package_after_install.sh | 8 ++ install/package_after_remove.sh | 3 + install/package_before_remove.sh | 6 + 5 files changed, 89 insertions(+), 81 deletions(-) create mode 100755 install/package_after_install.sh create mode 100755 install/package_after_remove.sh create mode 100755 install/package_before_remove.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea3075fc..14dca223 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,12 +25,6 @@ jobs: - name: Create full source ZIP archive and Signature run: | zip -9vr daed-full-src.zip . -x .git/\* - FILE=./daed-full-src.zip - DGST=$FILE.dgst - md5sum $FILE >>$DGST - shasum -a 1 $FILE >>$DGST - shasum -a 256 $FILE >>$DGST - shasum -a 512 $FILE >>$DGST - name: Upload artifact - full source uses: actions/upload-artifact@v3 @@ -182,25 +176,26 @@ jobs: - name: Smoking test if: matrix.goarch == 'amd64' && matrix.goamd64 == 'v1' run: ./bundled/${{ steps.get_filename.outputs.BUNDLE_NAME }} --version - - - name: Create binary ZIP archive and Signature - run: | - pushd bundled || exit 1 - zip -9vr ../${{ steps.get_filename.outputs.BUNDLE_NAME }}.zip . - popd || exit 1 - FILE=./${{ steps.get_filename.outputs.BUNDLE_NAME }}.zip - DGST=$FILE.dgst - md5sum $FILE >>$DGST - shasum -a 1 $FILE >>$DGST - shasum -a 256 $FILE >>$DGST - shasum -a 512 $FILE >>$DGST - + - name: Upload artifact - bundle + if: ${{ github.event_name != 'release' }} uses: actions/upload-artifact@v3 with: name: ${{ steps.get_filename.outputs.BUNDLE_NAME }} path: bundled/* + - name: Create binary ZIP archive + if: ${{ github.event_name == 'release' }} + run: | + zip -9vr ./${{ steps.get_filename.outputs.BUNDLE_NAME }}.zip ./bundled/* + + - name: Upload ZIP archive + if: ${{ github.event_name == 'release' }} + uses: nanoufo/action-upload-artifacts-and-release-assets@v1.5 + with: + path: | + ${{ steps.get_filename.outputs.BUNDLE_NAME }}.zip + - name: Build Linux packages if: ${{ env.GOARM != '5' && env.GOARM != '6' }} run: | @@ -213,6 +208,9 @@ jobs: --url 'https://github.com/daeuniverse/daed' --description "daed, A Modern Dashboard For dae." \ --maintainer "daed@dae.v2raya.org" --name daed --license 'MIT AGPL' \ --package daed-linux-$GOARCH$GOAMD64$GOARM.$package_manager \ + --after-install ../install/package_after_install.sh \ + --before-remove ../install/package_before_remove.sh \ + --after-remove ../install/package_after_remove.sh \ ./geoip.dat=/usr/share/daed/geoip.dat ./geosite.dat=/usr/share/daed/geosite.dat \ ./daed.service=/usr/lib/systemd/system/daed.service \ ./${{ steps.get_filename.outputs.BUNDLE_NAME }}=/usr/bin/daed @@ -221,73 +219,55 @@ jobs: cp bundled/daed-linux-$GOARCH$GOAMD64$GOARM.deb installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.deb cp bundled/daed-linux-$GOARCH$GOAMD64$GOARM.rpm installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.rpm cp bundled/daed-linux-$GOARCH$GOAMD64$GOARM.pacman installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.pkg.tar.zst - ls | grep -E ".deb|.pkg.tar.zst|.rpm" - for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm");do - md5sum $package >> $package.dgst - shasum -a 1 $package >> $package.dgst - shasum -a 256 $package >> $package.dgst - shasum -a 512 $package >> $package.dgst - cat $package.dgst - done fi - - name: Upload artifact - packages - if: ${{ github.event_name != 'release' && env.GOARM != '5' && env.GOARM != '6' }} + - name: Upload Linux packages + if: ${{ env.GOARM != '5' && env.GOARM != '6' }} uses: nanoufo/action-upload-artifacts-and-release-assets@v1.5 with: path: | installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.deb installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.rpm installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.pkg.tar.zst - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.deb.dgst - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.rpm.dgst - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.pkg.tar.zst.dgst - - - name: Upload Linux packages to GitHub release - if: ${{ github.event_name == 'release' && env.GOARM != '5' && env.GOARM != '6' }} - uses: softprops/action-gh-release@v1 - with: - files: | - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.deb - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.rpm - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.pkg.tar.zst - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.deb.dgst - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.rpm.dgst - installer-${{ steps.get_filename.outputs.BUNDLE_NAME }}.pkg.tar.zst.dgst - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload artifact - bundle-all - uses: actions/upload-artifact@v3 - with: - name: bundled-all - path: ${{ steps.get_filename.outputs.BUNDLE_NAME }}.zip upload-release: if: github.event_name == 'release' needs: [full-src, build-bundle] runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v3 - with: - name: daed-full-src - path: release/ - - - uses: actions/download-artifact@v3 + - name: Download all artifacts + uses: actions/download-artifact@v3 with: - name: bundled-all path: release/ - - name: Display structure of downloaded files - run: ls -R - working-directory: release + - name: Prepare files for upload + run: | + cp release/*/*.deb ./ + cp release/*/*.rpm ./ + cp release/*/*.pkg.tar.zst ./ + cp release/*/*.zip ./ + zip -9vr web.zip release/web + tar -zcvf web.tar.gz release/web + zip -9vr daed-full-src.zip release/daed-full-src/* + tar -zcvf daed-full-src.tar.gz release/daed-full-src + for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm|.zip|.tar.gz");do + md5sum $package >> $package.dgst + shasum -a 1 $package >> $package.dgst + shasum -a 256 $package >> $package.dgst + shasum -a 512 $package >> $package.dgst + done - name: Upload Release uses: softprops/action-gh-release@v1 with: tag_name: ${{ github.ref }} files: | - release/* + *zip + *tar.gz + *pkg.tar.zst + *deb + *rpm + *dgst generate_release_notes: true upload-prerelease: @@ -295,19 +275,27 @@ jobs: needs: [full-src, build-bundle] runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v3 - with: - name: daed-full-src - path: release/ - - - uses: actions/download-artifact@v3 + - name: Download all artifacts + uses: actions/download-artifact@v3 with: - name: bundled-all path: release/ - - name: Display structure of downloaded files - run: ls -R - working-directory: release + - name: Prepare files for upload + run: | + cp release/*/*.deb ./ + cp release/*/*.rpm ./ + cp release/*/*.pkg.tar.zst ./ + cp release/*/*.zip ./ + zip -9vr web.zip release/web + tar -zcvf web.tar.gz release/web + zip -9vr daed-full-src.zip release/daed-full-src/* + tar -zcvf daed-full-src.tar.gz release/daed-full-src + for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm|.zip|.tar.gz");do + md5sum $package >> $package.dgst + shasum -a 1 $package >> $package.dgst + shasum -a 256 $package >> $package.dgst + shasum -a 512 $package >> $package.dgst + done - name: Delete current release assets uses: 8Mi-Tech/delete-release-assets-action@main @@ -321,6 +309,11 @@ jobs: with: tag_name: Prerelease files: | - release/* + *zip + *tar.gz + *pkg.tar.zst + *deb + *rpm + *dgst prerelease: true generate_release_notes: true diff --git a/.github/workflows/sync-upstream-source.yml b/.github/workflows/sync-upstream-source.yml index be4c1772..ba04e3a3 100644 --- a/.github/workflows/sync-upstream-source.yml +++ b/.github/workflows/sync-upstream-source.yml @@ -10,7 +10,7 @@ on: wing-sync-message: type: string required: true - default: 'chore(sync): upgrade dae-wing' + default: 'chore: upgrade dae-wing' jobs: sync-wing: @@ -22,15 +22,13 @@ jobs: submodules: 'recursive' fetch-depth: 0 - - name: Sync dae-wing upstream + - name: sync wing run: | git checkout ${{ inputs.wing-head }} working-directory: wing - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 + - uses: stefanzweifel/git-auto-commit-action@v4 with: + commit_message: ${{ inputs.wing-sync-message }} + create_branch: true branch: sync-wing - delete-branch: true - title: ${{ inputs.wing-sync-message }} - commit-message: ${{ inputs.wing-sync-message }} diff --git a/install/package_after_install.sh b/install/package_after_install.sh new file mode 100755 index 00000000..b61835e4 --- /dev/null +++ b/install/package_after_install.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +systemctl daemon-reload + +if [ "$(systemctl is-active daed)" == 'active' ]; then + systemctl restart daed.service + echo "Restart daed service, it might take a while." +fi diff --git a/install/package_after_remove.sh b/install/package_after_remove.sh new file mode 100755 index 00000000..ab20f7b0 --- /dev/null +++ b/install/package_after_remove.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +systemctl daemon-reload diff --git a/install/package_before_remove.sh b/install/package_before_remove.sh new file mode 100755 index 00000000..ced3446d --- /dev/null +++ b/install/package_before_remove.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +if [ "$(systemctl is-active daed)" == 'active' ]; then + systemctl stop daed.service + echo "stopped daed service, daed will be removed." +fi From c3abeb8c8ac652e965f0512adb835ddb2764ce52 Mon Sep 17 00:00:00 2001 From: Markson Hon <50002150+MarksonHon@users.noreply.github.com> Date: Sat, 17 Jun 2023 16:34:30 +0800 Subject: [PATCH 2/2] build.yml: daed-full-src.zip should not be zipped again --- .github/workflows/build.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14dca223..a3c4d758 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: - name: Upload artifact - full source uses: actions/upload-artifact@v3 with: - name: daed-full-src + name: daed-full-src.zip path: daed-full-src.zip build-web: @@ -176,7 +176,7 @@ jobs: - name: Smoking test if: matrix.goarch == 'amd64' && matrix.goamd64 == 'v1' run: ./bundled/${{ steps.get_filename.outputs.BUNDLE_NAME }} --version - + - name: Upload artifact - bundle if: ${{ github.event_name != 'release' }} uses: actions/upload-artifact@v3 @@ -247,10 +247,7 @@ jobs: cp release/*/*.pkg.tar.zst ./ cp release/*/*.zip ./ zip -9vr web.zip release/web - tar -zcvf web.tar.gz release/web - zip -9vr daed-full-src.zip release/daed-full-src/* - tar -zcvf daed-full-src.tar.gz release/daed-full-src - for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm|.zip|.tar.gz");do + for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm|.zip");do md5sum $package >> $package.dgst shasum -a 1 $package >> $package.dgst shasum -a 256 $package >> $package.dgst @@ -263,7 +260,6 @@ jobs: tag_name: ${{ github.ref }} files: | *zip - *tar.gz *pkg.tar.zst *deb *rpm @@ -287,10 +283,7 @@ jobs: cp release/*/*.pkg.tar.zst ./ cp release/*/*.zip ./ zip -9vr web.zip release/web - tar -zcvf web.tar.gz release/web - zip -9vr daed-full-src.zip release/daed-full-src/* - tar -zcvf daed-full-src.tar.gz release/daed-full-src - for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm|.zip|.tar.gz");do + for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm|.zip");do md5sum $package >> $package.dgst shasum -a 1 $package >> $package.dgst shasum -a 256 $package >> $package.dgst @@ -310,7 +303,6 @@ jobs: tag_name: Prerelease files: | *zip - *tar.gz *pkg.tar.zst *deb *rpm