Skip to content

Commit

Permalink
ci: separate release from pre-release build
Browse files Browse the repository at this point in the history
  • Loading branch information
piyoki committed Jun 18, 2023
1 parent 89e85dd commit 7f727fa
Show file tree
Hide file tree
Showing 2 changed files with 278 additions and 57 deletions.
275 changes: 275 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
name: Publish Pre-release
run-name: Publish prerelease ${{ github.ref_name }} by @${{ github.actor }}

on:
workflow_dispatch:
push:
tags:
- 'v*.*.*rc'
- 'v*.*.*p*'

jobs:
checkout-full-src:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Download wing vendor
run: |
git submodule update --init --recursive
export GOMODCACHE="${PWD}"/go-mod
go mod download -modcacherw
cd dae-core && go mod download -modcacherw && cd ..
find "$GOMODCACHE" -maxdepth 1 ! -name "cache" ! -name "go-mod" -exec rm -rf {} \;
sed -i 's/#export GOMODCACHE=$(PWD)\/go-mod/export GOMODCACHE=$(PWD)\/go-mod/' Makefile
working-directory: wing

- name: Create full source ZIP archive and Signature
run: |
zip -9vr daed-full-src.zip . -x .git/\*
- name: Upload artifact - full source
uses: actions/upload-artifact@v3
with:
name: daed-full-src.zip
path: daed-full-src.zip

build-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: latest

- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: latest

- name: Build
run: |
pnpm install
pnpm build
- name: Upload artifact - web
uses: actions/upload-artifact@v3
with:
name: web
path: dist

build-bundle:
needs: [build-web]
runs-on: ubuntu-latest

strategy:
matrix:
goos: [linux]
goarch: [arm64, 386, riscv64, mips64, mips64le, mipsle, mips]

include:
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7

# BEGIN Linux AMD64 v1 v2 v3
- goos: linux
goarch: amd64
goamd64: v1
- goos: linux
goarch: amd64
goamd64: v2
- goos: linux
goarch: amd64
goamd64: v3
# END Linux AMD64 v1 v2 v3

# BEGIN Linux mips
- goos: linux
goarch: mips64
cgo_enabled: 1
cc: mips64-linux-gnuabi64-gcc
- goos: linux
goarch: mips64le
cgo_enabled: 1
cc: mips64el-linux-gnuabi64-gcc
- goos: linux
goarch: mipsle
cgo_enabled: 1
cc: mipsel-linux-gnu-gcc
- goos: linux
goarch: mips
cgo_enabled: 1
cc: mips-linux-gnu-gcc
# END Linux mips
fail-fast: false

env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
GOAMD64: ${{ matrix.goamd64 }}
CGO_ENABLED: ${{ matrix.cgo_enabled || 0 }}
CC: ${{ matrix.cc }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get the version
id: get_version
env:
REF: ${{ github.ref }}
run: |
if [[ "$REF" == "refs/tags/v"* ]]; then
tag=${REF##*/}
version=${tag}
package_version="${tag:1}"
else
date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
count=$(git rev-list --count HEAD)
commit=$(git rev-parse --short HEAD)
version="unstable-$date.r${count}.$commit"
package_version="$date.r${count}.$commit"
fi
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$package_version" >> $GITHUB_OUTPUT
echo "PACKAGE_VERSION=$package_version" >> $GITHUB_ENV
- name: Get the filename
id: get_filename
run: |
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOAMD64\"].friendlyName" -r < install/friendly-filenames.json)
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
echo "BUNDLE_NAME=daed-$_NAME" >> $GITHUB_OUTPUT
- name: Install mips build dependencies
if: ${{ startsWith(matrix.goarch, 'mips') }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-mips64-linux-gnuabi64 gcc-mips64el-linux-gnuabi64 gcc-mips-linux-gnu gcc-mipsel-linux-gnu
- name: Download artifact - web
uses: actions/download-artifact@v3
with:
name: web
path: dist/

- name: make
run: |
mkdir -p ./bundled/
export VERSION=${{ steps.get_version.outputs.VERSION }}
export GOFLAGS="-trimpath -modcacherw"
export OUTPUT=bundled/${{ steps.get_filename.outputs.BUNDLE_NAME }}
make
cp ./install/daed.service ./bundled/
curl -L -o ./bundled/geoip.dat https://github.com/v2rayA/dist-v2ray-rules-dat/raw/master/geoip.dat
curl -L -o ./bundled/geosite.dat https://github.com/v2rayA/dist-v2ray-rules-dat/raw/master/geosite.dat
- name: Upload artifact - bundle
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_filename.outputs.BUNDLE_NAME }}
path: bundled/*

- name: Smoking test
if: matrix.goarch == 'amd64' && matrix.goamd64 == 'v1'
run: ./bundled/${{ steps.get_filename.outputs.BUNDLE_NAME }} --version

- name: Build Linux packages
if: ${{ env.GOARM != '5' && env.GOARM != '6' }}
run: |
if [ "$GOARM" != '5' ] && [ "$GOARM" != '6' ];then
sudo apt install -y libarchive-tools rpm
sudo gem install fpm -v 1.15.1
pushd bundled || exit 1
for package_manager in deb rpm pacman; do
fpm -s dir -t "$package_manager" -a $GOARCH --version "$PACKAGE_VERSION" \
--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 \
--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
done
popd || exit 1
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
fi
- 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
upload-prerelease:
needs: [checkout-full-src, build-bundle]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: release/

- name: Prepare files for upload
run: |
cp release/*/*.deb ./
cp release/*/*.rpm ./
cp release/*/*.pkg.tar.zst ./
cp release/*/*.zip ./
pushd release
zip -9vr ../web.zip web/*
for zip_file in $(ls | grep -E "^daed-linux*");do
pushd $zip_file
zip -9r ../../"$zip_file".zip ./*
popd
done
popd
for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm|.zip");do
echo "$(md5sum $package)"" md5" >> $package.dgst
echo "$(shasum -a 1 $package)"" sha1" >> $package.dgst
echo "$(shasum -a 256 $package)"" sha256" >> $package.dgst
echo "$(shasum -a 512 $package)"" sha512" >> $package.dgst
done
echo "Show files are going to upload..."
ls -lh | grep -E ".deb|.pkg.tar.zst|.rpm|.zip"
- name: Delete current release assets
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
deleteOnlyFromDrafts: false

- name: Upload Prerelease
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
files: |
*zip
*pkg.tar.zst
*deb
*rpm
*dgst
prerelease: true
generate_release_notes: true
60 changes: 3 additions & 57 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Release
run-name: Publish prerelease ${{ github.ref_name }} by @${{ github.actor }}
name: Publish Release
run-name: Publish release ${{ github.ref_name }} by @${{ github.actor }}

on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
# will come back add add input here

jobs:
checkout-full-src:
Expand Down Expand Up @@ -265,55 +263,3 @@ jobs:
*rpm
*dgst
generate_release_notes: true

upload-prerelease:
needs: [checkout-full-src, build-bundle]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: release/

- name: Prepare files for upload
run: |
cp release/*/*.deb ./
cp release/*/*.rpm ./
cp release/*/*.pkg.tar.zst ./
cp release/*/*.zip ./
pushd release
zip -9vr ../web.zip web/*
for zip_file in $(ls | grep -E "^daed-linux*");do
pushd $zip_file
zip -9r ../../"$zip_file".zip ./*
popd
done
popd
for package in $(ls | grep -E ".deb|.pkg.tar.zst|.rpm|.zip");do
echo "$(md5sum $package)"" md5" >> $package.dgst
echo "$(shasum -a 1 $package)"" sha1" >> $package.dgst
echo "$(shasum -a 256 $package)"" sha256" >> $package.dgst
echo "$(shasum -a 512 $package)"" sha512" >> $package.dgst
done
echo "Show files are going to upload..."
ls -lh | grep -E ".deb|.pkg.tar.zst|.rpm|.zip"
- name: Delete current release assets
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
deleteOnlyFromDrafts: false

- name: Upload Prerelease
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
files: |
*zip
*pkg.tar.zst
*deb
*rpm
*dgst
prerelease: true
generate_release_notes: true

0 comments on commit 7f727fa

Please sign in to comment.