Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(build.yml): add Linux package hooks #40

Merged
merged 3 commits into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 67 additions & 74 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines -25 to -30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove?

Copy link
Contributor

@mzz2017 mzz2017 Jun 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Maybe you want to calculate all digests in one step, but I cannot see daed-full-src.zip.dgst. Something goes wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c3abeb8 does not fix up the problem daed-full-src.zip should not be zipped again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

daed-full-src.zip is actually zipped by the Action workflow, and when upload it to Action artifacts, it will be zipped again as daed-full-src.zip.zip, so in the last release job, we should only generate the dgst file for it, but not zip it again like web files.
图片


- name: Upload artifact - full source
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -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/[email protected]
with:
path: |
${{ steps.get_filename.outputs.BUNDLE_NAME }}.zip

- name: Build Linux packages
if: ${{ env.GOARM != '5' && env.GOARM != '6' }}
run: |
Expand All @@ -213,6 +208,9 @@ jobs:
--url 'https://github.com/daeuniverse/daed' --description "daed, A Modern Dashboard For dae." \
--maintainer "[email protected]" --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
Expand All @@ -221,93 +219,83 @@ 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/[email protected]
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:
if: github.ref == 'refs/heads/develop'
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
Expand All @@ -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
12 changes: 5 additions & 7 deletions .github/workflows/sync-upstream-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
8 changes: 8 additions & 0 deletions install/package_after_install.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions install/package_after_remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

systemctl daemon-reload
6 changes: 6 additions & 0 deletions install/package_before_remove.sh
Original file line number Diff line number Diff line change
@@ -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