add A record for backup http trigger notification #95
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cross-Build | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*" | |
pull_request: | |
paths: | |
- '.github/workflows/exp-cross-build.yml' | |
jobs: | |
check_commit_msg: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Commit Message | |
run: | | |
git clone https://github.com/yaklang/yaklang && cd yaklang | |
git fetch --all | |
if [[ -n "$GITHUB_HEAD_REF" ]]; then | |
REF=$GITHUB_HEAD_REF | |
else | |
REF=${GITHUB_REF#refs/*/} | |
fi | |
git checkout $REF | |
echo "Switched to $REF" | |
git checkout $REF | |
echo "generate commit messages ... " | |
./scripts/generate-commit.sh | |
echo "-------------" | |
# 检查 /tmp/raw_commit_message.txt 文件是否存在 | |
if [ ! -f /tmp/raw_commit_message.txt ]; then | |
echo "Error: /tmp/raw_commit_message.txt does not exist." | |
exit 1 | |
fi | |
echo "/tmp/raw_commit_message.txt is existed continue..." | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: raw_commit_message.txt | |
path: /tmp/raw_commit_message.txt | |
build_and_upload_to_oss: | |
needs: check_commit_msg | |
strategy: | |
matrix: | |
os: | |
- windows | |
- macos-amd64 | |
- macos-arm64 | |
- linux-amd64 | |
- linux-arm64 | |
include: | |
- os: windows | |
binary: yak_windows_amd64.exe | |
env: $env:GITHUB_ENV | |
- os: macos-amd64 | |
binary: yak_darwin_amd64 | |
env: $GITHUB_ENV | |
- os: macos-arm64 | |
binary: yak_darwin_arm64 | |
env: $GITHUB_ENV | |
- os: linux-amd64 | |
binary: yak_linux_amd64 | |
env: $GITHUB_ENV | |
- os: linux-arm64 | |
binary: yak_linux_arm64 | |
env: $GITHUB_ENV | |
runs-on: ${{ contains(matrix.os, 'windows') && 'windows-latest' || 'macos-14' }} | |
steps: | |
# build | |
- uses: actions/checkout@v2 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: "./go.mod" | |
id: go | |
- name: Get Repo tags | |
run: | | |
go run common/yak/cmd/yak.go repos-tag -o tags.txt | |
echo "YAK_TAG=$(cat tags.txt)" >> ${{ matrix.env }} | |
- name: Download CrossBuild GCC(Linux x64) | |
if: matrix.os == 'linux-amd64' | |
run: | | |
brew tap messense/macos-cross-toolchains | |
brew install x86_64-unknown-linux-gnu | |
x86_64-linux-gnu-gcc -v | |
- name: Download CrossBuild GCC(Linux arm64) | |
if: matrix.os == 'linux-arm64' | |
run: | | |
brew tap messense/macos-cross-toolchains | |
brew install aarch64-unknown-linux-gnu | |
aarch64-linux-gnu-gcc -v | |
- name: Generate Document | |
run: go run common/yak/yakdoc/generate_doc/generate_doc.go common/yak/yakdoc/doc/doc.gob.gzip | |
- name: Codec Methods Document | |
run: go run common/yak/yaklib/codec/codegrpc/doc/codec_doc.go common/yak/yaklib/codec/codegrpc/codec.gob.gzip | |
- name: Initialize License Machine | |
run: go run common/xlic/cmd/initializer.go --ak ${{ secrets.OSS_KEY_ID }} --sk ${{ secrets.OSS_KEY_SECRET }} | |
- name: Build For Linux(linux, amd64) | |
run: | | |
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build -ldflags "-linkmode external -extldflags '-static' -s -w -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(git show -s --format=%cd)' -X 'main.yakVersion=${{ env.YAK_TAG }}'" -o "./yak_linux_amd64" -v common/yak/cmd/yak.go && ls | |
if: matrix.os == 'linux-amd64' | |
- name: Build For Linux(linux, arm64) | |
run: | | |
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -ldflags "-linkmode external -extldflags '-static' -s -w -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(git show -s --format=%cd)' -X 'main.yakVersion=${{ env.YAK_TAG }}'" -o "./yak_linux_arm64" -v common/yak/cmd/yak.go && ls | |
if: matrix.os == 'linux-arm64' | |
- name: Build For MacOS(arm64) | |
run: | | |
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(git show -s --format=%cd)' -X 'main.yakVersion=${{ env.YAK_TAG }}'" -o "./yak_darwin_arm64" -v common/yak/cmd/yak.go && ls | |
if: matrix.os == 'macos-arm64' | |
- name: Build For MacOS(amd64) | |
run: | | |
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(git show -s --format=%cd)' -X 'main.yakVersion=${{ env.YAK_TAG }}'" -o "./yak_darwin_amd64" -v common/yak/cmd/yak.go && ls | |
if: matrix.os == 'macos-amd64' | |
- name: Build For Windows | |
run: | | |
go build -ldflags "-s -w -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(git show -s --format=%cd)' -X 'main.yakVersion=${{ env.YAK_TAG }}'" -o ./yak_windows_amd64.exe -v common/yak/cmd/yak.go | |
if: runner.os == 'Windows' | |
# release | |
- name: Generate Checksums | |
run: | | |
go run common/yak/cmd/yak.go sha256 -f ${{ matrix.binary }} | |
echo "SHA256=${{ matrix.binary }}.sha256.txt" >> ${{ matrix.env }} | |
- name: debug info | |
run: | | |
echo "env.YAK_TAG PRODUCT_BINARY=${{ matrix.binary }}" | |
echo "env.YAK_TAG YAK_TAG=${{ env.YAK_TAG }}" | |
echo "env.YAK_TAG SHA256=${{ env.SHA256 }}" | |
- name: Show Current Dir | |
run: ls | |
if: runner.os != 'Windows' | |
- name: Upload Binaries To aliyun-oss | |
run: | | |
go run common/yak/cmd/yak.go upload-oss --ak ${{ secrets.OSS_KEY_ID }} --sk ${{ secrets.OSS_KEY_SECRET }} -t 5 -f '${{ matrix.binary }}:/yak/${{ env.YAK_TAG }}/${{ matrix.binary }};${{ env.SHA256 }}:/yak/${{ env.YAK_TAG }}/${{ env.SHA256 }}' | |
# upload assets | |
- name: Upload binary artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.binary }} | |
path: ./${{ matrix.binary }} | |
- name: Upload sha256 checksums artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.SHA256 }} | |
path: ./${{ env.SHA256 }} | |
check_version_and_github_release: | |
runs-on: ubuntu-latest | |
needs: build_and_upload_to_oss | |
steps: | |
- uses: actions/checkout@v2 | |
# download assets | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: ${{ github.workspace }} | |
- name: Get Repo tags | |
run: | | |
pwd && ls -lh && chmod +x ./yak_linux_amd64 | |
./yak_linux_amd64 repos-tag -o tags.txt | |
echo "YAK_TAG=$(cat tags.txt)" >> $GITHUB_ENV | |
- name: Checkout Tags Version | |
run: echo ${{ env.YAK_TAG }} | |
- name: Publish Release INFO | |
continue-on-error: true | |
run: | | |
# 定义文件路径 | |
raw_commit_file="./raw_commit_message.txt" | |
# 检查文件行数 | |
line_count=$(wc -l < "$raw_commit_file") | |
# 如果行数超过3行,输出111 | |
if [ "$line_count" -gt 3 ]; then | |
./yak_linux_amd64 ./scripts/output_release_info.yak --ai-type openai --apikey ${{ secrets.OPENAI_APIKEY }} --filename ./raw_commit_message.txt --ai-model gpt-4-0613 | |
ls | grep release | |
fi | |
if [[ -f release_note.en.txt ]]; then | |
echo "Uploading release_note.en.txt to oss" | |
cat release_note.en.txt | head -n 100 | |
./yak_linux_amd64 upload-oss -f 'release_note.en.txt:/yak/${{ env.YAK_TAG }}/release_note.en.txt' -ak ${{ secrets.OSS_KEY_ID }} -sk ${{ secrets.OSS_KEY_SECRET }} -t 5 | |
fi | |
if [[ -f release_note.txt ]]; then | |
echo "Uploading release_note.txt to oss" | |
cat release_note.txt | head -n 100 | |
./yak_linux_amd64 upload-oss -f 'release_note.txt:/yak/${{ env.YAK_TAG }}/release_note.txt' -ak ${{ secrets.OSS_KEY_ID }} -sk ${{ secrets.OSS_KEY_SECRET }} -t 5 | |
fi | |
- name: Push Version Info to OSS | |
run: | | |
echo "start to handle versions" | |
if [ -f current_version.txt ]; then rm current_version.txt; fi | |
if [ -f new_history_versions.txt ]; then rm new_history_versions.txt; fi | |
echo "${{ env.YAK_TAG }}" > current_version.txt | |
# check if history_versions.txt url 404 existed | |
HISTORY_URL="https://aliyun-oss.yaklang.com/yak/version-info/history_versions.txt" | |
if wget --spider --server-response "$HISTORY_URL" 2>&1 | grep 'HTTP/.* 200' >/dev/null; then | |
echo "Downloading history_versions.txt..." | |
wget -O history_versions.txt -q $HISTORY_URL | |
cat ./current_version.txt ./history_versions.txt > new_history_versions.txt | |
else | |
echo "history_versions.txt not found or server did not return HTTP 200 for $HISTORY_URL, skipping download." | |
cat ./current_version.txt > new_history_versions.txt | |
fi | |
echo "Uploading version.txt to oss" | |
cat new_history_versions.txt | head -n 100 | |
cat new_history_versions.txt | head -n 100 > active_versions.txt | |
./yak_linux_amd64 upload-oss -f 'new_history_versions.txt:/yak/version-info/history_versions.txt' -ak ${{ secrets.OSS_KEY_ID }} -sk ${{ secrets.OSS_KEY_SECRET }} -t 5 | |
./yak_linux_amd64 upload-oss -f 'active_versions.txt:/yak/version-info/active_versions.txt' -ak ${{ secrets.OSS_KEY_ID }} -sk ${{ secrets.OSS_KEY_SECRET }} -t 5 | |
- name: Publish Release | |
uses: softprops/action-gh-release@v2 | |
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') && !contains(env.YAK_TAG, 'alpha') }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
with: | |
name: ${{ env.YAK_TAG }} | |
tag_name: ${{ env.YAK_TAG }} | |
body: | | |
Release ${{ env.YAK_TAG }} | |
draft: false | |
prerelease: false | |
files: | | |
yak_windows_amd64.exe | |
yak_linux_amd64 | |
yak_linux_arm64 | |
yak_darwin_amd64 | |
yak_darwin_arm64 | |
yak_windows_amd64.exe.sha256.txt | |
yak_linux_amd64.sha256.txt | |
yak_linux_arm64.sha256.txt | |
yak_darwin_amd64.sha256.txt | |
yak_darwin_arm64.sha256.txt | |
- name: Build Docker Image(Tag) | |
run: | | |
echo "start to format tag name: ${{ env.YAK_TAG }}" | |
FORMATTEDTAG="${{ env.YAK_TAG }}" | |
formatted_tag="${FORMATTEDTAG//\//-}" | |
echo "start to build docker image..." | |
cp ./yak_linux_amd64 ./common/yak/cmd/docker/ && cp ./yak_linux_arm64 ./common/yak/cmd/docker/ | |
echo "copy yak_linux_amd64 and yak_linux_arm64 to docker folder..." | |
echo "start to check buildx env and create builder" | |
docker buildx ls && docker buildx create --name yaklang-builder --use | |
echo "start to login docker" | |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
echo "start to build docker image..." | |
docker buildx build --platform linux/amd64,linux/arm64 -t v1ll4n/yaklang:$formatted_tag --build-arg VERSION=${{ env.YAK_TAG }} ./common/yak/cmd/docker/ --push | |
echo "Check if the latest label should be updated(formatted_tag is not start with dev)" | |
if [[ ! $formatted_tag == dev* ]]; then | |
echo "start to update latest tag" | |
docker buildx build --platform linux/amd64,linux/arm64 -t v1ll4n/yaklang:latest --build-arg VERSION=${{ env.YAK_TAG }} ./common/yak/cmd/docker/ --push | |
fi |