This commit is contained in:
deniscerri 2024-12-04 21:07:08 +01:00
parent 8525c66587
commit 4957810984
No known key found for this signature in database
GPG key ID: 95C43D517D830350

View file

@ -75,61 +75,61 @@ jobs:
Repository: ${{ github.repository }} Repository: ${{ github.repository }}
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
# Start Creating Pre-Release # # Start Creating Pre-Release
- name: Start Pre-Release # - name: Start Pre-Release
uses: actions/checkout@v4 # uses: actions/checkout@v4
with: # with:
persist-credentials: false # persist-credentials: false
# returns null if no pre-release exists # # returns null if no pre-release exists
- name: Get Commit SHA of Latest Pre-release # - name: Get Commit SHA of Latest Pre-release
run: | # run: |
# Install Required Packages # # Install Required Packages
sudo apt-get updated # sudo apt-get updated
sudo apt-get install -y curl jq # sudo apt-get install -y curl jq
echo "COMMIT_SHA_TAG=$(jq -r 'map(select(.prerelease)) | first | .tag_name' <<< $(curl -s https://api.github.com/repos/deniscerri/ytdlnis/releases))" >> $GITHUB_ENV # echo "COMMIT_SHA_TAG=$(jq -r 'map(select(.prerelease)) | first | .tag_name' <<< $(curl -s https://api.github.com/repos/deniscerri/ytdlnis/releases))" >> $GITHUB_ENV
#
- run: gh release delete ${{ env.COMMIT_SHA_TAG }} --cleanup-tag # - run: gh release delete ${{ env.COMMIT_SHA_TAG }} --cleanup-tag
if: (env.COMMIT_SHA_TAG != 'null' && contains('Auto-Release', env.COMMIT_SHA_TAG)) # if: (env.COMMIT_SHA_TAG != 'null' && contains('Auto-Release', env.COMMIT_SHA_TAG))
env: # env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# Make sure that an old ci that still runs on main doesn't recreate a prerelease # # Make sure that an old ci that still runs on main doesn't recreate a prerelease
- name: Check Pullable Commits # - name: Check Pullable Commits
id: check_commits # id: check_commits
run: | # run: |
git fetch # git fetch
CHANGES=$(git rev-list HEAD..origin/main --count) # CHANGES=$(git rev-list HEAD..origin/main --count)
echo "CHANGES=$CHANGES" >> $GITHUB_ENV # echo "CHANGES=$CHANGES" >> $GITHUB_ENV
#
- name: Get Release Name # - name: Get Release Name
id: get_last_release_tag # id: get_last_release_tag
run: | # run: |
LASTRELEASE=$(curl "https://api.github.com/repos/deniscerri/ytdlnis/releases/latest") # LASTRELEASE=$(curl "https://api.github.com/repos/deniscerri/ytdlnis/releases/latest")
ISPRERELEASE=$(echo $LASTRELEASE | jq -r '.prerelease') # ISPRERELEASE=$(echo $LASTRELEASE | jq -r '.prerelease')
NEWRELEASENAME=$(echo $LASTRELEASE | jq -r '.name') # NEWRELEASENAME=$(echo $LASTRELEASE | jq -r '.name')
if ! $ISPRERELEASE; then NEWRELEASENAME=$(echo $NEWRELEASENAME'.1'); else NEWRELEASENAME=$(echo $NEWRELEASENAME | sed -E 's/(.*\.)([0-9]+)$/echo "\1$((\2 + 1))"/e'); fi # if ! $ISPRERELEASE; then NEWRELEASENAME=$(echo $NEWRELEASENAME'.1'); else NEWRELEASENAME=$(echo $NEWRELEASENAME | sed -E 's/(.*\.)([0-9]+)$/echo "\1$((\2 + 1))"/e'); fi
echo "NEWRELEASENAME=$NEWRELEASENAME" >> $GITHUB_ENV # echo "NEWRELEASENAME=$NEWRELEASENAME" >> $GITHUB_ENV
#
- name: Get last commit SHA # - name: Get last commit SHA
id: last_commit # id: last_commit
run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV # run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
#
- name: Get commmit date # - name: Get commmit date
id: commit_date # id: commit_date
run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV # run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV
#
#
# Create a new pre-release, the other upload_binaries.yml will upload the binaries # # Create a new pre-release, the other upload_binaries.yml will upload the binaries
# to this pre-release. # # to this pre-release.
- name: Create Prerelease # - name: Create Prerelease
if: github.ref.name == 'main' && env.CHANGES == '0' # if: github.ref.name == 'main' && env.CHANGES == '0'
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981 # uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
with: # with:
name: ${{ env.NEWRELEASENAME }} [Auto-Release] [${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}] # name: ${{ env.NEWRELEASENAME }} [Auto-Release] [${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}]
tag_name: v${{ env.NEWRELEASENAME }}-beta # tag_name: v${{ env.NEWRELEASENAME }}-beta
body: ${{ github.event.commits[0].message }} # body: ${{ github.event.commits[0].message }}
prerelease: true # prerelease: true
files: | # files: |
${{ env.main_project_module }}/build/outputs/apk/release/* # ${{ env.main_project_module }}/build/outputs/apk/release/*
${{ env.main_project_module }}/build/outputs/apk/debug/* # ${{ env.main_project_module }}/build/outputs/apk/debug/*