Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
xishang0128 committed Feb 26, 2024
1 parent d37385a commit a1262ce
Showing 1 changed file with 183 additions and 183 deletions.
366 changes: 183 additions & 183 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,189 +135,189 @@ jobs:
echo "CGO_ENABLED=1" >> $GITHUB_ENV
echo "BUILDTAG=" >> $GITHUB_ENV
# - name: build core
# env:
# GOOS: ${{matrix.jobs.goos}}
# GOARCH: ${{matrix.jobs.goarch}}
# GOAMD64: ${{matrix.jobs.goamd64}}
# GOARM: ${{matrix.jobs.arm}}
# GOMIPS: ${{matrix.jobs.mips}}
# run: |
# echo $CGO_ENABLED
# go build -v -tags "with_gvisor" -trimpath -ldflags "${BUILDTAG} -X 'github.com/metacubex/mihomo/constant.Version=${VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -w -s -buildid="
# if [ "${{matrix.jobs.goos}}" = "windows" ]; then
# cp mihomo.exe mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}.exe
# zip -r mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.zip mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}.exe
# else
# cp mihomo mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}
# gzip -c mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}} > mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.gz
# rm mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}
# fi

# - name: Create DEB package
# if: ${{ matrix.jobs.goos == 'linux' && !contains(matrix.jobs.goarch, 'mips') }}
# run: |
# sudo apt-get install dpkg
# if [ "${{matrix.jobs.goarch}}" = "loong64" ]; then
# ARCH=loongarch64
# else
# ARCH=${{matrix.jobs.goarch}}
# fi
# mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/DEBIAN
# mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/bin
# mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/mihomo
# mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/systemd/system/
# mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/share/licenses/mihomo

# cp mihomo mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/bin/mihomo
# cp LICENSE mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/share/licenses/mihomo/
# cp .github/mihomo.service mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/systemd/system/

# cat > mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/mihomo/config.yaml <<EOF
# mixed-port: 7890
# external-controller: 127.0.0.1:9090
# EOF

# cat > mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/DEBIAN/control <<EOF
# Package: mihomo
# Version: 1.18.2-${VERSION}
# Section:
# Priority: extra
# Architecture: ${ARCH}
# Maintainer: MetaCubeX <none@example.com>
# Homepage: https://wiki.metacubex.one/
# Description: The universal proxy platform.
# EOF

# dpkg-deb -Z gzip --build mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}

# - name: Convert DEB to RPM
# if: ${{ matrix.jobs.goos == 'linux' && !contains(matrix.jobs.goarch, 'mips') }}
# run: |
# sudo apt-get install -y alien
# alien --to-rpm --scripts mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.deb
# mv mihomo*.rpm mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.rpm

# - name: Convert DEB to PKG
# if: ${{ matrix.jobs.goos == 'linux' && !contains(matrix.jobs.goarch, 'mips') && !contains(matrix.jobs.goarch, 'loong') }}
# run: |
# docker pull archlinux
# docker run --rm -v ./:/mnt archlinux bash -c "
# pacman -Syu pkgfile base-devel --noconfirm
# curl -L https://github.com/helixarch/debtap/raw/master/debtap > /usr/bin/debtap
# chmod 755 /usr/bin/debtap
# debtap -u
# debtap -Q /mnt/mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.deb
# "
# mv mihomo*.pkg.tar.zst mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.pkg.tar.zst

# - name: Save version
# run: |
# echo ${VERSION} > version.txt
# shell: bash

# - name: Archive production artifacts
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.jobs.goos }}-${{ matrix.jobs.output }}
# path: |
# mihomo*.gz
# mihomo*.deb
# mihomo*.rpm
# mihomo*.pkg.tar.zst
# mihomo*.zip
# version.txt

# Upload-Prerelease:
# permissions: write-all
# if: ${{ github.ref_type == 'branch' && !startsWith(github.event_name, 'pull_request') }}
# needs: [build]
# runs-on: ubuntu-latest
# steps:
# - name: Download all workflow run artifacts
# uses: actions/download-artifact@v4
# with:
# path: bin/
# merge-multiple: true

# - name: Delete current release assets
# uses: 8Mi-Tech/delete-release-assets-action@main
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# tag: Prerelease-${{ github.ref_name }}
# deleteOnlyFromDrafts: false
# - name: Set Env
# run: |
# echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
# shell: bash

# - name: Tag Repo
# uses: richardsimko/update-tag@v1
# with:
# tag_name: Prerelease-${{ github.ref_name }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: build core
env:
GOOS: ${{matrix.jobs.goos}}
GOARCH: ${{matrix.jobs.goarch}}
GOAMD64: ${{matrix.jobs.goamd64}}
GOARM: ${{matrix.jobs.arm}}
GOMIPS: ${{matrix.jobs.mips}}
run: |
echo $CGO_ENABLED
go build -v -tags "with_gvisor" -trimpath -ldflags "${BUILDTAG} -X 'github.com/metacubex/mihomo/constant.Version=${VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -w -s -buildid="
if [ "${{matrix.jobs.goos}}" = "windows" ]; then
cp mihomo.exe mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}.exe
zip -r mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.zip mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}.exe
else
cp mihomo mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}
gzip -c mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}} > mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.gz
rm mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}
fi
- name: Create DEB package
if: ${{ matrix.jobs.goos == 'linux' && !contains(matrix.jobs.goarch, 'mips') }}
run: |
sudo apt-get install dpkg
if [ "${{matrix.jobs.goarch}}" = "loong64" ]; then
ARCH=loongarch64
else
ARCH=${{matrix.jobs.goarch}}
fi
mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/DEBIAN
mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/bin
mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/mihomo
mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/systemd/system/
mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/share/licenses/mihomo
cp mihomo mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/bin/mihomo
cp LICENSE mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/share/licenses/mihomo/
cp .github/mihomo.service mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/systemd/system/
cat > mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/mihomo/config.yaml <<EOF
mixed-port: 7890
external-controller: 127.0.0.1:9090
EOF
cat > mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/DEBIAN/control <<EOF
Package: mihomo
Version: 1.18.2-${VERSION}
Section:
Priority: extra
Architecture: ${ARCH}
Maintainer: MetaCubeX <none@example.com>
Homepage: https://wiki.metacubex.one/
Description: The universal proxy platform.
EOF
dpkg-deb -Z gzip --build mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}
- name: Convert DEB to RPM
if: ${{ matrix.jobs.goos == 'linux' && !contains(matrix.jobs.goarch, 'mips') }}
run: |
sudo apt-get install -y alien
alien --to-rpm --scripts mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.deb
mv mihomo*.rpm mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.rpm
- name: Convert DEB to PKG
if: ${{ matrix.jobs.goos == 'linux' && !contains(matrix.jobs.goarch, 'mips') && !contains(matrix.jobs.goarch, 'loong') }}
run: |
docker pull archlinux
docker run --rm -v ./:/mnt archlinux bash -c "
pacman -Syu pkgfile base-devel --noconfirm
curl -L https://github.com/helixarch/debtap/raw/master/debtap > /usr/bin/debtap
chmod 755 /usr/bin/debtap
debtap -u
debtap -Q /mnt/mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.deb
"
mv mihomo*.pkg.tar.zst mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.pkg.tar.zst
- name: Save version
run: |
echo ${VERSION} > version.txt
shell: bash

- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.jobs.goos }}-${{ matrix.jobs.output }}
path: |
mihomo*.gz
mihomo*.deb
mihomo*.rpm
mihomo*.pkg.tar.zst
mihomo*.zip
version.txt
Upload-Prerelease:
permissions: write-all
if: ${{ github.ref_type == 'branch' && !startsWith(github.event_name, 'pull_request') }}
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
path: bin/
merge-multiple: true

- name: Delete current release assets
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: Prerelease-${{ github.ref_name }}
deleteOnlyFromDrafts: false
- name: Set Env
run: |
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
shell: bash

- name: Tag Repo
uses: richardsimko/update-tag@v1
with:
tag_name: Prerelease-${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - run: |
# cat > release.txt << 'EOF'
# Release created at ${{ env.BUILDTIME }}
# Synchronize ${{ github.ref_name }} branch code updates, keeping only the latest version
# <br>
# [我应该下载哪个文件? / Which file should I download?](https://github.com/MetaCubeX/mihomo/wiki/FAQ)
# [二进制文件筛选 / Binary file selector](https://metacubex.github.io/Meta-Docs/startup/#_1)
# [查看文档 / Docs](https://metacubex.github.io/Meta-Docs/)
# EOF

# - name: Upload Prerelease
# uses: softprops/action-gh-release@v1
# if: ${{ success() }}
# with:
# tag_name: Prerelease-${{ github.ref_name }}
# files: |
# bin/*
# prerelease: true
# generate_release_notes: true
# body_path: release.txt

# Upload-Release:
# permissions: write-all
# if: ${{ github.ref_type=='tag' }}
# needs: [build]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: Get tags
# run: |
# echo "CURRENTVERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# git fetch --tags
# echo "PREVERSION=$(git describe --tags --abbrev=0 HEAD^)" >> $GITHUB_ENV

# - name: Generate release notes
# run: |
# cp ./.github/genReleaseNote.sh ./
# bash ./genReleaseNote.sh -v ${PREVERSION}...${CURRENTVERSION}
# rm ./genReleaseNote.sh

# - uses: actions/download-artifact@v4
# with:
# path: bin/
# merge-multiple: true

# - name: Display structure of downloaded files
# run: ls -R
# working-directory: bin

# - name: Upload Release
# uses: softprops/action-gh-release@v1
# if: ${{ success() }}
# with:
# tag_name: ${{ github.ref_name }}
# files: bin/*
# generate_release_notes: true
# body_path: release.md
- run: |
cat > release.txt << 'EOF'
Release created at ${{ env.BUILDTIME }}
Synchronize ${{ github.ref_name }} branch code updates, keeping only the latest version
<br>
[我应该下载哪个文件? / Which file should I download?](https://github.com/MetaCubeX/mihomo/wiki/FAQ)
[二进制文件筛选 / Binary file selector](https://metacubex.github.io/Meta-Docs/startup/#_1)
[查看文档 / Docs](https://metacubex.github.io/Meta-Docs/)
EOF
- name: Upload Prerelease
uses: softprops/action-gh-release@v1
if: ${{ success() }}
with:
tag_name: Prerelease-${{ github.ref_name }}
files: |
bin/*
prerelease: true
generate_release_notes: true
body_path: release.txt

Upload-Release:
permissions: write-all
if: ${{ github.ref_type=='tag' }}
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get tags
run: |
echo "CURRENTVERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
git fetch --tags
echo "PREVERSION=$(git describe --tags --abbrev=0 HEAD^)" >> $GITHUB_ENV
- name: Generate release notes
run: |
cp ./.github/genReleaseNote.sh ./
bash ./genReleaseNote.sh -v ${PREVERSION}...${CURRENTVERSION}
rm ./genReleaseNote.sh
- uses: actions/download-artifact@v4
with:
path: bin/
merge-multiple: true

- name: Display structure of downloaded files
run: ls -R
working-directory: bin

- name: Upload Release
uses: softprops/action-gh-release@v1
if: ${{ success() }}
with:
tag_name: ${{ github.ref_name }}
files: bin/*
generate_release_notes: true
body_path: release.md


0 comments on commit a1262ce

Please sign in to comment.