修改自动化提交描述 #102
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: push_lib_widget | |
on: [ push ] | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Lint | |
run: | | |
./gradlew :lib:widget:lint | |
- 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)) | |
echo "当前版本号 Versions: $prev_version_1.$prev_version_2.$prev_version_3" | |
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: | | |
# Update the versionCode in the build file | |
new_version="${{ steps.generate_version.outputs.new_version }}" | |
sed -i "s/^VERSION_NAME=.*/VERSION_NAME=$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: publish mavenCentral | |
env: | |
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} | |
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} | |
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }} | |
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYID }} | |
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }} | |
run: | | |
./gradlew :lib:widget:publish | |
- name: push versionCode | |
run: | | |
git config --global --add safe.directory /__w/DangoUnit/DangoUnit | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
PREV_COMMIT_MESSAGE=$(git log -1 --pretty=format:%s) | |
NEW_COMMIT_MESSAGE="Update versionCode --> $PREV_COMMIT_MESSAGE" | |
git commit -am "$NEW_COMMIT_MESSAGE" | |
git push | |
- name: tag versionCode | |
run: | | |
git config --global --add safe.directory /__w/DangoUnit/DangoUnit | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
new_tag="lib_widget_v_${{ steps.generate_version.outputs.new_version }}" | |
git tag $new_tag | |
git push origin $new_tag | |
- name: Upload | |
uses: actions/upload-artifact@v2 | |
with: | |
name: aar | |
path: ./lib/widget/build/outputs/aar/ |