fix: gradlew line endings

fix: beta.yml

fix: multiline beta.yml

Update beta.yml

Update beta.yml

Update beta.yml

Update beta.yml

fix: beta.yml newline

Update beta.yml

fix: finding last sha

fix: beta .yml
This commit is contained in:
rebelonion 2024-02-04 23:25:41 -06:00
parent a7e7bd0230
commit 855c7e623a
2 changed files with 60 additions and 17 deletions

View file

@ -17,16 +17,49 @@ jobs:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
fetch-depth: 10 fetch-depth: 0
- name: Get Last 10 Commits
id: get_commits - name: Download last SHA artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: beta.yml
name: last-sha
path: .
continue-on-error: true
- name: Get Commits Since Last Run
run: | run: |
echo 'COMMIT_LOG<<EOF' >> $GITHUB_ENV if [ -f last_sha.txt ]; then
git log ${{ github.event.before }}..${{ github.sha }} --pretty=format:"%s" -10 | while IFS= read -r line; do LAST_SHA=$(cat last_sha.txt)
echo "$line" >> $GITHUB_ENV else
done # Fallback to first commit if no previous SHA available
echo 'EOF' >> $GITHUB_ENV LAST_SHA=$(git rev-list --max-parents=0 HEAD)
fi
echo "Commits since $LAST_SHA:"
# Accumulate commit logs in a shell variable
COMMIT_LOGS=$(git log $LAST_SHA..HEAD --pretty=format:"%h - %s")
# URL-encode the newline characters for GitHub Actions
COMMIT_LOGS="${COMMIT_LOGS//'%'/'%25'}"
COMMIT_LOGS="${COMMIT_LOGS//$'\n'/'%0A'}"
COMMIT_LOGS="${COMMIT_LOGS//$'\r'/'%0D'}"
# Append the encoded commit logs to the COMMIT_LOG environment variable
echo "COMMIT_LOG=${COMMIT_LOGS}" >> $GITHUB_ENV
# Debugging: Print the variable to check its content
echo "$COMMIT_LOGS"
shell: /usr/bin/bash -e {0}
env:
CI: true
- name: Save Current SHA for Next Run
run: echo ${{ github.sha }} > last_sha.txt
- name: Upload Current SHA as Artifact
uses: actions/upload-artifact@v2
with:
name: last-sha
path: last_sha.txt
- name: Set variables - name: Set variables
run: | run: |
@ -42,16 +75,16 @@ jobs:
distribution: 'temurin' distribution: 'temurin'
java-version: 17 java-version: 17
cache: gradle cache: gradle
- name: Decode Keystore File - name: Decode Keystore File
run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > $GITHUB_WORKSPACE/key.keystore run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > $GITHUB_WORKSPACE/key.keystore
- name: List files in the directory - name: List files in the directory
run: ls -l run: ls -l
- name: Make gradlew executable - name: Make gradlew executable
run: chmod +x ./gradlew run: chmod +x ./gradlew
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew assembleAlpha -Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/key.keystore -Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} -Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} -Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }} run: ./gradlew assembleAlpha -Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/key.keystore -Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} -Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} -Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }}
@ -60,14 +93,24 @@ jobs:
with: with:
name: Dantotsu name: Dantotsu
path: "app/build/outputs/apk/alpha/app-alpha.apk" path: "app/build/outputs/apk/alpha/app-alpha.apk"
- name: Upload APK to Discord - name: Upload APK to Discord
shell: bash shell: bash
run: | run: |
commit_messages=$(echo "$COMMIT_LOG") commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g')
contentbody=$( jq -Rsa . <<< "Alpha-Build: <@719439449423085569> **${{ env.VERSION }}**\n\n$commit_messages" ) # Truncate commit messages if they are too long
max_length=1900 # Adjust this value as needed
if [ ${#commit_messages} -gt $max_length ]; then
commit_messages="${commit_messages:0:$max_length}... (truncated)"
fi
contentbody=$( jq -Rsa . <<< "Alpha-Build: <@719439449423085569> **$VERSION**: $commit_messages" )
curl -F "payload_json={\"content\":${contentbody}}" -F "dantotsu_debug=@app/build/outputs/apk/alpha/app-alpha.apk" ${{ secrets.DISCORD_WEBHOOK }} curl -F "payload_json={\"content\":${contentbody}}" -F "dantotsu_debug=@app/build/outputs/apk/alpha/app-alpha.apk" ${{ secrets.DISCORD_WEBHOOK }}
env:
COMMIT_LOG: ${{ env.COMMIT_LOG }}
VERSION: ${{ env.VERSION }}
- name: Delete Old Pre-Releases - name: Delete Old Pre-Releases
id: delete-pre-releases id: delete-pre-releases
uses: sgpublic/delete-release-action@master uses: sgpublic/delete-release-action@master
@ -76,4 +119,4 @@ jobs:
pre-release-keep-count: 3 pre-release-keep-count: 3
pre-release-drop-tag: true pre-release-drop-tag: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
gradlew vendored
View file

@ -59,7 +59,7 @@ die () {
echo echo
exit 1 exit 1
} }
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false