Skip to content

feat: Config

feat: Config #88

name: push_lib_widget
on: [ push ]
#on:
# push:
# paths:
# - '**'
jobs:
prepare:
runs-on: ubuntu-latest
# container:
# image: registry.cn-shanghai.aliyuncs.com/dango/android_ci:latest # 指定您的自定义 Docker 镜像及其标签
# options: --platform linux/amd64
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: 检查当前版本
id: generate_version
run: |
prev_version_1=$(grep "VERSION_NAME=" lib/widget/gradle.properties | sed -E 's/VERSION_NAME=([0-9]+)\.[0-9]+\.[0-9]+/\1/')
prev_version_2=$(grep "VERSION_NAME=" lib/widget/gradle.properties | sed -E 's/VERSION_NAME=[0-9]+\.([0-9]+)\.[0-9]+/\1/')
prev_version_3=$(grep "VERSION_NAME=" lib/widget/gradle.properties | sed -E 's/VERSION_NAME=[0-9]+\.[0-9]+\.([0-9]+)/\1/')
new_version_1=$prev_version_1
new_version_2=$prev_version_2
new_version_3=$((prev_version_3 + 1))
if [ $new_version_3 -gt 999 ]; then
new_version_2=$((new_version_2 + 1))
new_version_3=$((new_version_3 % 1000))
if [ $new_version_2 -gt 99 ]; then
new_version_1=$((new_version_1 + 1))
new_version_2=$((new_version_2 % 100))
fi
fi
formatted_version=$(printf "%s" "$new_version_1.$new_version_2.$new_version_3")
echo "new_version=$formatted_version" >> $GITHUB_OUTPUT
echo "Formatted Versions: $formatted_version"
- name: 之前保存的版本号
run: |
echo "new_version = ${{ steps.generate_version.outputs.new_version }}"
- name: 修改本地版本号
run: |
# Update the versionCode in the build file
sed -i 's/\([0-9]\+\)$/${{ steps.generate_version.outputs.new_version }}/' lib/widget/gradle.properties
- name: 打印本地版本号
run: |
# Update the versionCode in the build file
grep "VERSION_NAME" lib/widget/gradle.properties | grep '[0-9]\+$'
# - name: 上传2
# run: |
# pwd
# echo $GITHUB_TOKEN
# git config --global --add safe.directory /__w/DangoUnit/DangoUnit
# git config --global user.email "[email protected]"
# git config --global user.name "GitHub Actions"
# git commit -am "Update versionCode"
# git push
# - name: 发布
# run: |
# ./gradlew :lib:widget:publish
# build:
# runs-on: ubuntu-latest
#
## container:
## image: registry.cn-shanghai.aliyuncs.com/dango/android_ci:latest # 指定您的自定义 Docker 镜像及其标签
## options: --platform linux/amd64
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2
#
# - name: 打印环境变量
# run: |
# env
#
# - name: Display Commit SHA
# run: |
# echo "Current Commit SHA: ${{ github.sha }}"
#
# - name: Display Branch/Tag Name
# run: |
# echo "Current Ref: ${{ github.ref }}"
#
# - name: Display Commit Author
# run: |
# echo "Commit Author: ${{ github.actor }}"
# echo "Commit Author: ${{ github.actor }}"
#
# - name: Display Repository Name
# run: |
# echo "Repository: ${{ github.repository }}"
#
# # 获取git log
# - name: Get git log
# id: git_log
# run: |
# pwd
# git config --global --add safe.directory /__w/DangoUnit/DangoUnit
# updateLog=`git log --pretty=format:"%s" -1`
# echo "updateLog=$updateLog" >> $GITHUB_ENV
# git log --pretty=format:"%s" -1
#
# - name: Show Latest Commit
# run: |
# git log -n 1