Skip to content

XGo Docker Build

XGo Docker Build #83

Workflow file for this run

name: XGo Docker Build
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * MON'
jobs:
XGo_Docker_Build:
name: XGo Docker Build
runs-on: ubuntu-latest
steps:
-
name: Private Actions Checkout
uses: actions/checkout@v4
-
name: Check The Update
id: update
run: |
set -ex
curl -sLo tmpREADME.md "$(curl -sLH "Authorization: token ${{ SECRETS.TOKEN_GITHUB }}" "https://api.github.com/repos/crazy-max/xgo/contents/README.md" | grep download_url | cut -d '"' -f 4)"
if [[ "$(md5sum README.md | cut -d ' ' -f 1)" != "$(md5sum tmpREADME.md | cut -d ' ' -f 1)" ]]; then
rm README.md
mv tmpREADME.md README.md
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Add changes by Awvs_Update_Action" -a
else
echo 未检测到更新
echo "status=false" >> $GITHUB_OUTPUT
fi
-
name: checkTag
id: checkTag
run: |
tagName=$(jq -r .tag_name <(curl -sLH "Authorization: token ${{ SECRETS.TOKEN_GITHUB }}" "https://api.github.com/repos/crazy-max/xgo/releases/latest"))
echo "tagName=${tagName}" >> $GITHUB_OUTPUT
-
name: Push changes
uses: ad-m/github-push-action@master
if: steps.update.outputs.status == 'true'
with:
github_token: ${{ SECRETS.TOKEN_GITHUB }}
branch: ${{ github.ref }}
-
name: Docker Setup QEMU
uses: docker/setup-qemu-action@v3
-
name: Docker Setup Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker Login in Aliyun
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.DOCKERHUB_ACCOUNT_ALIYUN }}
password: ${{ secrets.DOCKERHUB_PASSWORD_ALIYUN }}
-
name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
push: true
tags: |
registry.cn-hangzhou.aliyuncs.com/xrsec/xgo:latest
-
name: Generate software
run: |
set -ex
git clone https://github.com/crazy-max/xgo.git
cd xgo
sed -i "s|ghcr.io/crazy-max/xgo|registry.cn-hangzhou.aliyuncs.com/xrsec/xgo|g" xgo.go
-
name: Build with xgo
uses: crazy-max/ghaction-xgo@v3
with:
xgo_version: latest
go_version: ${{ matrix.go_version }}
working_dir: ./xgo
dest: bin
prefix: xgo
targets: android/386, android/amd64, android/arm, android/arm64, darwin/amd64, darwin/arm64, freebsd/386, freebsd/amd64, freebsd/arm, freebsd/arm64, linux/386, linux/amd64, linux/arm, linux/arm64, linux/mips, linux/mips64, linux/mips64le, linux/mipsle, linux/ppc64, linux/ppc64le, linux/riscv64, linux/s390x, netbsd/386, netbsd/amd64, netbsd/arm, netbsd/arm64, openbsd/386, openbsd/amd64, openbsd/arm, openbsd/arm64, openbsd/mips64, windows/386, windows/amd64, windows/arm, windows/arm64
v: false
x: false
race: false
ldflags: -s -w
buildmode: default
-
name: Delete old Releases
uses: dev-drprasad/[email protected]
with:
repo: ${{ github.repository }}
keep_latest: 3
delete_tag_pattern: ""
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
-
name: Make release
uses: softprops/action-gh-release@v2
with:
files: "xgo/bin/**"
body_path: .github/body.txt
name: "Go CGO cross compiler( AliYun )"
tag_name: ${{ steps.checkTag.outputs.tagName }}
draft: false
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
-
name: Get Data
id: getDingData
run: |
set -ex
# 输出仓库名
REPOSITORY="${{GITHUB.REPOSITORY}}"
echo "REPOSITORY=${REPOSITORY#*/}" >> $GITHUB_OUTPUT
# 获取用户仓库信息
# RESPONSE="$(curl -sLm 10 https://api.github.com/repos/${{ GITHUB.REPOSITORY }})"
# 建议填写自己的 TOKEN
RESPONSE="$(curl -sLm 10 https://api.github.com/repos/${{ GITHUB.REPOSITORY }} -H "Authorization: token ${{ SECRETS.TOKEN_GITHUB }}")"
# 获取 用户仓库 设置的 描述,如果为空,可能是没有使用 TOKEN
DESCRIPTION="$(jq -r .description <(echo ${RESPONSE}))"
echo "DESCRIPTION=${DESCRIPTION}" >> $GITHUB_OUTPUT
# 获取 用户仓库 设置的 URL, 如果没有就输出 Github 地址
URL="$(jq -r .homepage <(echo ${RESPONSE}))"
if [[ "${URL}" == "null" || "${URL}" == "" ]]; then
echo "URL=${{ GITHUB.SERVER_URL }}/${{ GITHUB.REPOSITORY }}" >> $GITHUB_OUTPUT
else
echo "URL=${URL}" >> $GITHUB_OUTPUT
fi
-
name: Send dingding notify
uses: zcong1993/actions-ding@master
with:
dingToken: ${{ SECRETS.DING_TOKEN }}
secret: ${{ SECRETS.DING_SECRET }}
body: |
{
"msgtype": "link",
"link": {
"text": "${{ steps.getDingData.outputs.DESCRIPTION }}",
"title": "${{ steps.getDingData.outputs.REPOSITORY }} WorkFlow ${{ GITHUB.JOB }} Success!",
"picUrl": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
"messageUrl": "${{ steps.getDingData.outputs.URL }}"
}
}