98 lines
4.0 KiB
YAML
98 lines
4.0 KiB
YAML
name: 自动版本发布
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- main
|
||
|
||
jobs:
|
||
create-readme:
|
||
runs-on: ubuntu-latest
|
||
|
||
if: "contains(github.event.head_commit.message, 'Release')"
|
||
|
||
steps:
|
||
- name: 检查本地是否已经有ubuntu-latest镜像
|
||
id: check_ubuntu_image
|
||
run: |
|
||
if docker image inspect ubuntu:latest >/dev/null 2>&1; then
|
||
echo "Ubuntu latest image is already present locally. Skipping pull."
|
||
echo "::set-output name=should_pull::false"
|
||
else
|
||
echo "Ubuntu latest image is not present locally. Will pull."
|
||
echo "::set-output name=should_pull::true"
|
||
fi
|
||
|
||
- name: 本地没有构建机器,下载ubuntu-latest
|
||
if: steps.check_ubuntu_image.outputs.should_pull == 'true'
|
||
run: docker pull ubuntu:latest
|
||
|
||
- name: 替换软件源为国内软件源
|
||
run: |
|
||
cat /etc/os-release
|
||
sudo rm -f /etc/apt/sources.list
|
||
sudo rm -f /etc/apt/sources.list.d/*
|
||
sudo tee /etc/apt/sources.list <<EOF
|
||
deb http://mirrors.ustc.edu.cn/ubuntu/ noble main restricted universe multiverse
|
||
deb-src http://mirrors.ustc.edu.cn/ubuntu/ noble main restricted universe multiverse
|
||
deb http://mirrors.ustc.edu.cn/ubuntu/ noble-security main restricted universe multiverse
|
||
deb-src http://mirrors.ustc.edu.cn/ubuntu/ noble-security main restricted universe multiverse
|
||
deb http://mirrors.ustc.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
|
||
deb-src http://mirrors.ustc.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
|
||
deb http://mirrors.ustc.edu.cn/ubuntu/ noble-backports main restricted universe multiverse
|
||
deb-src http://mirrors.ustc.edu.cn/ubuntu/ noble-backports main restricted universe multiverse
|
||
EOF
|
||
|
||
- name: 安装 tea 工具
|
||
run: |
|
||
# 更新 apt 缓存
|
||
sudo apt-get update
|
||
# 安装 tea 工具
|
||
sudo apt-get install -y tea golang
|
||
|
||
# - name: 删除本地仓库副本
|
||
# env:
|
||
# REPO_NAME: ${{ github.event.repository.name }}
|
||
# run: |
|
||
# if [ -d "$REPO_NAME" ]; then
|
||
# rm -rf "$REPO_NAME"
|
||
# fi
|
||
|
||
- name: 检出仓库
|
||
env:
|
||
GITEA_TOKEN: ${{ secrets.AUTOGENERATE }}
|
||
GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
||
CLEAN_REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
||
run: |
|
||
# CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}"
|
||
# git clone "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" .
|
||
|
||
- name: 检出仓库
|
||
uses: actions/checkout@v4
|
||
|
||
- name: 设置 Git 身份
|
||
run: |
|
||
git config user.name "${{ github.actor }}"
|
||
git config user.email "${{ github.actor }}@users.noreply.git.linuxacme.com"
|
||
|
||
- name: 生成版本号
|
||
id: generate_version
|
||
run: |
|
||
VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oP 'Release v\K[0-9.]+')
|
||
echo "::set-output name=version::$VERSION"
|
||
|
||
- name: 创建标签
|
||
run: |
|
||
# git tag -d v${{ steps.generate_version.outputs.version }}
|
||
# git push origin --delete v${{ steps.generate_version.outputs.version }}
|
||
git tag -a v${{ steps.generate_version.outputs.version }} -m "Release v${{ steps.generate_version.outputs.version }}"
|
||
git push origin v${{ steps.generate_version.outputs.version }}
|
||
|
||
- name: 创建发布
|
||
uses: https://gitea.com/actions/release-action@main
|
||
with:
|
||
tag_name: v${{ steps.generate_version.outputs.version }}
|
||
release_name: Release v${{ steps.generate_version.outputs.version }}
|
||
body: |
|
||
这是版本 v${{ steps.generate_version.outputs.version }} 的发布说明。
|
||
你可以在这里详细描述这个版本的变更内容。 |