2023-02-19 01:23:06 +08:00
name : Build
2022-05-02 00:59:41 +08:00
on :
2022-11-26 20:11:43 +08:00
workflow_dispatch :
2024-05-18 18:36:00 +08:00
inputs :
version :
description : "Tag version to release"
required : true
2022-05-02 00:59:41 +08:00
push :
2023-01-21 14:42:48 +08:00
paths-ignore :
2023-01-25 20:53:39 +08:00
- "docs/**"
- "README.md"
2023-04-03 20:03:18 +08:00
- ".github/ISSUE_TEMPLATE/**"
2022-05-02 00:59:41 +08:00
branches :
2022-05-02 01:14:30 +08:00
- Alpha
2023-02-19 01:23:06 +08:00
tags :
- "v*"
2023-01-15 21:51:33 +08:00
pull_request_target :
2022-05-02 00:59:41 +08:00
branches :
2022-05-02 01:14:30 +08:00
- Alpha
2023-03-06 00:49:34 +08:00
concurrency :
2024-05-20 19:46:15 +08:00
group : "${{ github.workflow }}-${{ github.ref }}"
2023-03-06 00:49:34 +08:00
cancel-in-progress : true
2023-01-25 20:53:39 +08:00
env :
2023-12-05 21:07:21 +08:00
REGISTRY : docker.io
2022-05-02 00:59:41 +08:00
jobs :
2024-02-25 20:42:01 +08:00
build :
2023-01-15 15:04:27 +08:00
runs-on : ubuntu-latest
2023-01-15 21:51:33 +08:00
strategy :
matrix :
2024-02-25 20:42:01 +08:00
jobs :
- { goos: darwin, goarch: arm64, output : arm64 }
- { goos: darwin, goarch: amd64, goamd64: v1, output : amd64-compatible }
- { goos: darwin, goarch: amd64, goamd64: v3, output : amd64 }
- { goos: linux, goarch: '386', output : '386' }
2024-02-27 15:21:30 +08:00
- { goos: linux, goarch: amd64, goamd64: v1, output: amd64-compatible, test : test }
2024-02-25 20:42:01 +08:00
- { goos: linux, goarch: amd64, goamd64: v3, output : amd64 }
- { goos: linux, goarch: arm64, output : arm64 }
2024-03-30 23:04:03 +08:00
- { goos: linux, goarch: arm, goarm: '5', output : armv5 }
- { goos: linux, goarch: arm, goarm: '6', output : armv6 }
2024-02-25 20:42:01 +08:00
- { goos: linux, goarch: arm, goarm: '7', output : armv7 }
2024-08-19 10:01:05 +08:00
- { goos: linux, goarch: mips, gomips: hardfloat, output : mips-hardfloat }
- { goos: linux, goarch: mips, gomips: softfloat, output : mips-softfloat }
- { goos: linux, goarch: mipsle, gomips: hardfloat, output : mipsle-hardfloat }
- { goos: linux, goarch: mipsle, gomips: softfloat, output : mipsle-softfloat }
2024-02-25 20:42:01 +08:00
- { goos: linux, goarch: mips64, output : mips64 }
- { goos: linux, goarch: mips64le, output : mips64le }
2024-02-27 02:14:18 +08:00
- { goos: linux, goarch: loong64, output: loong64-abi1, abi : '1' }
- { goos: linux, goarch: loong64, output: loong64-abi2, abi : '2' }
2024-02-25 20:42:01 +08:00
- { goos: linux, goarch: riscv64, output : riscv64 }
- { goos: linux, goarch: s390x, output : s390x }
- { goos: windows, goarch: '386', output : '386' }
- { goos: windows, goarch: amd64, goamd64: v1, output : amd64-compatible }
- { goos: windows, goarch: amd64, goamd64: v3, output : amd64 }
- { goos: windows, goarch: arm, goarm: '7', output : armv7 }
- { goos: windows, goarch: arm64, output : arm64 }
- { goos: freebsd, goarch: '386', output : '386' }
- { goos: freebsd, goarch: amd64, goamd64: v1, output : amd64-compatible }
- { goos: freebsd, goarch: amd64, goamd64: v3, output : amd64 }
- { goos: freebsd, goarch: arm64, output : arm64 }
- { goos: android, goarch: '386', ndk: i686-linux-android34, output : '386' }
- { goos: android, goarch: amd64, ndk: x86_64-linux-android34, output : amd64 }
- { goos: android, goarch: arm, ndk: armv7a-linux-androideabi34, output : armv7 }
- { goos: android, goarch: arm64, ndk: aarch64-linux-android34, output : arm64-v8 }
2024-08-14 09:03:29 +08:00
# Go 1.22 with special patch can work on Windows 7
# https://github.com/MetaCubeX/go/commits/release-branch.go1.22/
- { goos: windows, goarch: '386', output: '386-go122', goversion : '1.22' }
- { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible-go122, goversion : '1.22' }
- { goos: windows, goarch: amd64, goamd64: v3, output: amd64-go122, goversion : '1.22' }
2024-05-15 09:14:34 +08:00
# Go 1.21 can revert commit `9e4385` to work on Windows 7
# https://github.com/golang/go/issues/64622#issuecomment-1847475161
# (OR we can just use golang1.21.4 which unneeded any patch)
- { goos: windows, goarch: '386', output: '386-go121', goversion : '1.21' }
- { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible-go121, goversion : '1.21' }
- { goos: windows, goarch: amd64, goamd64: v3, output: amd64-go121, goversion : '1.21' }
2024-02-27 15:21:30 +08:00
# Go 1.20 is the last release that will run on any release of Windows 7, 8, Server 2008 and Server 2012. Go 1.21 will require at least Windows 10 or Server 2016.
- { goos: windows, goarch: '386', output: '386-go120', goversion : '1.20' }
- { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible-go120, goversion : '1.20' }
- { goos: windows, goarch: amd64, goamd64: v3, output: amd64-go120, goversion : '1.20' }
2024-02-25 20:42:01 +08:00
2024-08-14 09:03:29 +08:00
# Go 1.22 is the last release that will run on macOS 10.15 Catalina. Go 1.23 will require macOS 11 Big Sur or later.
- { goos: darwin, goarch: arm64, output: arm64-go122, goversion : '1.22' }
- { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-compatible-go122, goversion : '1.22' }
- { goos: darwin, goarch: amd64, goamd64: v3, output: amd64-go122, goversion : '1.22' }
2024-02-27 15:21:30 +08:00
# Go 1.20 is the last release that will run on macOS 10.13 High Sierra or 10.14 Mojave. Go 1.21 will require macOS 10.15 Catalina or later.
- { goos: darwin, goarch: arm64, output: arm64-go120, goversion : '1.20' }
- { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-compatible-go120, goversion : '1.20' }
- { goos: darwin, goarch: amd64, goamd64: v3, output: amd64-go120, goversion : '1.20' }
2024-02-25 20:42:01 +08:00
2024-02-27 15:21:30 +08:00
# only for test
- { goos: linux, goarch: '386', output: '386-go120', goversion : '1.20' }
- { goos: linux, goarch: amd64, goamd64: v1, output: amd64-compatible-go120, goversion: '1.20', test : test }
- { goos: linux, goarch: amd64, goamd64: v3, output: amd64-go120, goversion : '1.20' }
2023-01-15 15:04:27 +08:00
steps :
2024-02-25 20:42:01 +08:00
- uses : actions/checkout@v4
2024-02-27 15:21:30 +08:00
- name : Set up Go
if : ${{ matrix.jobs.goversion == '' && matrix.jobs.goarch != 'loong64' }}
2024-02-25 20:42:01 +08:00
uses : actions/setup-go@v5
with :
2024-08-14 09:03:29 +08:00
go-version : '1.23'
2024-02-25 20:42:01 +08:00
2024-02-27 15:21:30 +08:00
- name : Set up Go
if : ${{ matrix.jobs.goversion != '' && matrix.jobs.goarch != 'loong64' }}
2024-02-25 20:42:01 +08:00
uses : actions/setup-go@v5
with :
2024-02-27 15:21:30 +08:00
go-version : ${{ matrix.jobs.goversion }}
2024-02-25 20:42:01 +08:00
2024-05-15 08:32:57 +08:00
- name : Set up Go1.22 loongarch abi1
2024-02-27 02:14:18 +08:00
if : ${{ matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }}
run : |
2024-08-13 00:57:08 +08:00
wget -q https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.22.4/go1.22.4.linux-amd64-abi1.tar.gz
sudo tar zxf go1.22.4.linux-amd64-abi1.tar.gz -C /usr/local
2024-02-27 23:11:56 +08:00
echo "/usr/local/go/bin" >> $GITHUB_PATH
2024-02-27 02:14:18 +08:00
2024-05-15 08:32:57 +08:00
- name : Set up Go1.22 loongarch abi2
2024-02-27 02:14:18 +08:00
if : ${{ matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '2' }}
run : |
2024-08-13 00:57:08 +08:00
wget -q https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.22.4/go1.22.4.linux-amd64-abi2.tar.gz
sudo tar zxf go1.22.4.linux-amd64-abi2.tar.gz -C /usr/local
2024-02-27 23:11:56 +08:00
echo "/usr/local/go/bin" >> $GITHUB_PATH
2024-02-27 02:14:18 +08:00
2024-08-14 10:13:57 +08:00
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
# this patch file only works on golang1.23.x
# that means after golang1.24 release it must be changed
# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.23/
# revert:
# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng"
# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7"
# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround"
# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries"
- name : Revert Golang1.23 commit for Windows7/8
if : ${{ matrix.jobs.goos == 'windows' && matrix.jobs.goversion == '' }}
run : |
cd $(go env GOROOT)
curl https://github.com/MetaCubeX/go/commit/9ac42137ef6730e8b7daca016ece831297a1d75b.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/21290de8a4c91408de7c2b5b68757b1e90af49dd.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/6a31d3fa8e47ddabc10bd97bff10d9a85f4cfb76.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/69e2eed6dd0f6d815ebf15797761c13f31213dd6.diff | patch --verbose -p 1
2024-05-12 00:10:51 +08:00
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
2024-05-12 13:32:07 +08:00
# this patch file only works on golang1.22.x
# that means after golang1.23 release it must be changed
2024-08-14 10:13:57 +08:00
# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.22/
2024-05-15 09:14:34 +08:00
# revert:
# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng"
# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7"
# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround"
2024-08-14 09:03:29 +08:00
# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries"
2024-05-12 13:32:07 +08:00
- name : Revert Golang1.22 commit for Windows7/8
2024-08-14 09:03:29 +08:00
if : ${{ matrix.jobs.goos == 'windows' && matrix.jobs.goversion == '1.22' }}
2024-05-12 00:10:51 +08:00
run : |
cd $(go env GOROOT)
2024-08-14 09:03:29 +08:00
curl https://github.com/MetaCubeX/go/commit/9779155f18b6556a034f7bb79fb7fb2aad1e26a9.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/ef0606261340e608017860b423ffae5c1ce78239.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/7f83badcb925a7e743188041cb6e561fc9b5b642.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/83ff9782e024cb328b690cbf0da4e7848a327f4f.diff | patch --verbose -p 1
2024-05-15 09:14:34 +08:00
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
- name : Revert Golang1.21 commit for Windows7/8
if : ${{ matrix.jobs.goos == 'windows' && matrix.jobs.goversion == '1.21' }}
run : |
cd $(go env GOROOT)
curl https://github.com/golang/go/commit/9e43850a3298a9b8b1162ba0033d4c53f8637571.diff | patch --verbose -R -p 1
2024-05-12 00:10:51 +08:00
2024-02-25 20:42:01 +08:00
- name : Set variables
2024-05-18 18:36:00 +08:00
if : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
run : echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
2024-02-25 20:42:01 +08:00
shell : bash
- name : Set variables
2024-05-18 18:36:00 +08:00
if : ${{ github.event_name != 'workflow_dispatch' && github.ref_name == 'Alpha' }}
run : echo "VERSION=alpha-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
2024-02-25 20:42:01 +08:00
shell : bash
- name : Set Time Variable
run : |
echo "BUILDTIME=$(date)" >> $GITHUB_ENV
echo "CGO_ENABLED=0" >> $GITHUB_ENV
echo "BUILDTAG=-extldflags --static" >> $GITHUB_ENV
2024-08-03 09:12:10 +08:00
echo "GOTOOLCHAIN=local" >> $GITHUB_ENV
2024-02-25 20:42:01 +08:00
- name : Setup NDK
if : ${{ matrix.jobs.goos == 'android' }}
uses : nttld/setup-ndk@v1
id : setup-ndk
with :
2024-08-13 00:57:08 +08:00
ndk-version : r27
2024-02-25 20:42:01 +08:00
- name : Set NDK path
if : ${{ matrix.jobs.goos == 'android' }}
run : |
echo "CC=${{steps.setup-ndk.outputs.ndk-path}}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{matrix.jobs.ndk}}-clang" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV
echo "BUILDTAG=" >> $GITHUB_ENV
2024-02-27 15:21:30 +08:00
- name : Test
if : ${{ matrix.jobs.test == 'test' }}
run : |
go test ./...
2024-08-26 18:33:04 +08:00
echo "---test with_gvisor---"
go test ./... -tags "with_gvisor" -count=1
2024-02-27 15:21:30 +08:00
2024-04-05 10:23:15 +08:00
- name : Update CA
2024-03-28 19:26:41 +08:00
run : |
sudo apt-get install ca-certificates
sudo update-ca-certificates
cp -f /etc/ssl/certs/ca-certificates.crt component/ca/ca-certificates.crt
2024-02-27 15:21:30 +08:00
- name : Build core
2024-02-25 20:42:01 +08:00
env :
GOOS : ${{matrix.jobs.goos}}
GOARCH : ${{matrix.jobs.goarch}}
GOAMD64 : ${{matrix.jobs.goamd64}}
2024-08-19 10:01:05 +08:00
GOARM : ${{matrix.jobs.goarm}}
GOMIPS : ${{matrix.jobs.gomips}}
2024-02-25 20:42:01 +08:00
run : |
2024-08-20 09:39:33 +08:00
go env
2024-02-25 20:42:01 +08:00
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
2024-02-27 23:11:56 +08:00
if [ "${{matrix.jobs.abi}}" = "1" ]; then
2024-02-27 02:14:18 +08:00
ARCH=loongarch64
2024-05-31 17:02:31 +08:00
elif [ "${{matrix.jobs.goarm}}" = "7" ]; then
ARCH=armhf
elif [ "${{matrix.jobs.goarch}}" = "arm" ]; then
ARCH=armel
2024-02-27 02:14:18 +08:00
else
ARCH=${{matrix.jobs.goarch}}
fi
2024-04-18 18:02:12 +08:00
PackageVersion=$(curl -s "https://api.github.com/repos/MetaCubeX/mihomo/releases/latest" | grep -o '"tag_name": "[^"]*' | grep -o '[^"]*$' | sed 's/v//g' )
if [ $(git branch | awk -F ' ' '{print $2}') = "Alpha" ]; then
PackageVersion="$(echo "${PackageVersion}" | awk -F '.' '{$NF = $NF + 1; print}' OFS='.')-${VERSION}"
fi
2024-02-25 20:42:01 +08:00
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
2024-04-18 18:02:12 +08:00
Version : ${PackageVersion}
2024-02-25 20:42:01 +08:00
Section :
Priority : extra
2024-02-27 02:14:18 +08:00
Architecture : ${ARCH}
2024-02-25 20:42:01 +08:00
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
2024-03-08 17:37:32 +08:00
# - name: Convert DEB to PKG
# if: ${{ matrix.jobs.goos == 'linux' && !contains(matrix.jobs.goarch, 'mips') && !contains(matrix.jobs.goarch, 'loong64') }}
# 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
2024-02-25 20:42:01 +08:00
- name : Save version
run : |
echo ${VERSION} > version.txt
shell : bash
- name : Archive production artifacts
uses : actions/upload-artifact@v4
with :
2024-05-20 19:46:15 +08:00
name : "${{ matrix.jobs.goos }}-${{ matrix.jobs.output }}"
2024-02-25 20:42:01 +08:00
path : |
mihomo*.gz
mihomo*.deb
mihomo*.rpm
mihomo*.zip
version.txt
2023-01-15 15:04:27 +08:00
2023-02-19 01:23:06 +08:00
Upload-Prerelease :
2023-01-15 21:51:33 +08:00
permissions : write-all
2024-05-18 18:36:00 +08:00
if : ${{ github.event_name != 'workflow_dispatch' && github.ref_type == 'branch' && !startsWith(github.event_name, 'pull_request') }}
2024-02-25 20:42:01 +08:00
needs : [ build]
2023-01-15 15:04:27 +08:00
runs-on : ubuntu-latest
steps :
2024-02-25 20:42:01 +08:00
- 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 }}
2024-02-05 13:56:39 +08:00
2024-02-25 20:42:01 +08:00
- 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
2023-02-19 01:23:06 +08:00
Upload-Release :
permissions : write-all
2024-05-18 18:36:00 +08:00
if : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
2024-02-25 20:42:01 +08:00
needs : [ build]
2023-02-19 01:23:06 +08:00
runs-on : ubuntu-latest
steps :
2024-05-18 18:36:00 +08:00
- name : Checkout
uses : actions/checkout@v4
with :
ref : Meta
fetch-depth : '0'
fetch-tags : 'true'
- name : Get tags
run : |
echo "CURRENTVERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
git fetch --tags
echo "PREVERSION=$(git describe --tags --abbrev=0 HEAD)" >> $GITHUB_ENV
2024-08-31 23:38:31 +08:00
- name : Force push Alpha branch to Meta
2024-05-18 18:36:00 +08:00
run : |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git fetch origin Alpha:Alpha
2024-08-31 23:38:31 +08:00
git push origin Alpha:Meta --force
2024-05-18 18:36:00 +08:00
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2024-08-31 23:38:31 +08:00
- name : Tag the commit on Alpha
2024-05-18 18:36:00 +08:00
run : |
2024-08-31 23:38:31 +08:00
git checkout Alpha
2024-05-18 18:36:00 +08:00
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
- 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@v2
if : ${{ success() }}
with :
tag_name : ${{ github.event.inputs.version }}
files : bin/*
body_path : release.md
2023-02-19 01:23:06 +08:00
2023-01-25 20:53:39 +08:00
Docker :
2023-12-16 22:03:32 +08:00
if : ${{ !startsWith(github.event_name, 'pull_request') }}
2023-01-25 20:53:39 +08:00
permissions : write-all
2024-02-25 20:42:01 +08:00
needs : [ build]
2023-01-25 20:53:39 +08:00
runs-on : ubuntu-latest
steps :
- name : Checkout repository
2024-02-05 13:56:39 +08:00
uses : actions/checkout@v4
2023-01-25 20:53:39 +08:00
with :
fetch-depth : 0
2024-02-05 13:56:39 +08:00
- uses : actions/download-artifact@v4
2023-01-25 20:53:39 +08:00
with :
path : bin/
2024-02-05 13:56:39 +08:00
merge-multiple : true
2023-01-25 20:53:39 +08:00
- name : Display structure of downloaded files
run : ls -R
working-directory : bin
- name : Set up QEMU
2024-02-15 21:48:48 +08:00
uses : docker/setup-qemu-action@v3
2023-01-25 20:53:39 +08:00
- name : Setup Docker buildx
2024-02-15 21:48:48 +08:00
uses : docker/setup-buildx-action@v3
2023-01-25 20:53:39 +08:00
with :
version : latest
2024-05-20 19:46:15 +08:00
2023-01-25 20:53:39 +08:00
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name : Extract Docker metadata
2024-05-20 19:46:15 +08:00
if : ${{ github.event_name != 'workflow_dispatch' }}
id : meta_alpha
2024-02-15 21:48:48 +08:00
uses : docker/metadata-action@v5
2023-01-25 20:53:39 +08:00
with :
2024-05-20 19:46:15 +08:00
images : '${{ env.REGISTRY }}/${{ github.repository }}'
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name : Extract Docker metadata
if : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
id : meta_release
uses : docker/metadata-action@v5
with :
images : '${{ env.REGISTRY }}/${{ github.repository }}'
tags : |
${{ github.event.inputs.version }}
flavor : |
latest=true
labels : org.opencontainers.image.version=${{ github.event.inputs.version }}
2023-01-25 20:53:39 +08:00
- name : Show files
run : |
ls .
ls bin/
2024-05-20 19:46:15 +08:00
2023-12-05 21:07:21 +08:00
- name : login to docker REGISTRY
2023-11-09 23:20:57 +08:00
uses : docker/login-action@v3
2023-01-25 20:53:39 +08:00
with :
2023-12-05 21:07:21 +08:00
registry : ${{ env.REGISTRY }}
username : ${{ secrets.DOCKER_HUB_USER }}
password : ${{ secrets.DOCKER_HUB_TOKEN }}
2023-01-25 20:53:39 +08:00
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name : Build and push Docker image
2024-05-20 19:46:15 +08:00
if : ${{ github.event_name != 'workflow_dispatch' }}
uses : docker/build-push-action@v5
with :
context : .
file : ./Dockerfile
push : ${{ github.event_name != 'pull_request' }}
platforms : |
linux/386
linux/amd64
linux/arm64
linux/arm/v7
tags : ${{ steps.meta_alpha.outputs.tags }}
labels : ${{ steps.meta_alpha.outputs.labels }}
- name : Build and push Docker image
if : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
2023-11-09 23:20:57 +08:00
uses : docker/build-push-action@v5
2023-01-25 20:53:39 +08:00
with :
context : .
file : ./Dockerfile
push : ${{ github.event_name != 'pull_request' }}
platforms : |
linux/386
linux/amd64
2023-11-09 23:20:57 +08:00
linux/arm64
2023-03-01 13:41:25 +08:00
linux/arm/v7
2024-05-20 19:46:15 +08:00
tags : ${{ steps.meta_release.outputs.tags }}
labels : ${{ steps.meta_release.outputs.labels }}