Skip to content

Commit

Permalink
build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodyOG authored Dec 3, 2024
1 parent 84b2b6c commit dffe89c
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: Build IceRaven Dark Theme (Auto-Release)

on:
workflow_dispatch: # Allows manual triggering
workflow_dispatch:
schedule:
- cron: '00 0 * * *'
release:
types: [created] # Triggers on new IceRaven releases
types: [created]
branches:
- main # Replace with your default branch if different

concurrency:
group: ${{ github.workflow }}
Expand All @@ -12,7 +16,7 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
steps: # Removed the conditional 'if' for manual runs
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
Expand All @@ -23,24 +27,31 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- name: Get Released APK URL and Version
- name: Get IceRaven Release Info
id: get_release
# Use a conditional to get the release information based on the event
run: |
if [[ github.event_name == 'release' ]]; then # Automation
ASSET_URL=$(gh release download ${{ github.event.release.tag_name }} -R fork-maintainers/iceraven-browser --pattern *arm64*forkRelease.apk | cut -f 1 -d ' ')
echo "ICERAVEN_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
elif [[ github.event_name == 'workflow_dispatch' ]]; then # Manual
ICERAVEN_VERSION="2.26.0" # Or input from workflow_dispatch
ASSET_URL="https://github.com/fork-maintainers/iceraven-browser/releases/download/iceraven-$ICERAVEN_VERSION/iceraven-$ICERAVEN_VERSION-browser-arm64-v8a-forkRelease.apk" # Construct the URL
echo "ICERAVEN_VERSION=$ICERAVEN_VERSION" >> $GITHUB_OUTPUT
if [[ github.event_name == 'release' ]]; then # Automated build (new release)
LATEST_RELEASE=$(jq -r '.assets[] | select(.name | contains("arm64") and contains("forkRelease.apk")) | .browser_download_url' < <(gh release view ${{ github.event.release.tag_name }} -R fork-maintainers/iceraven-browser --json assets))
echo "ICERAVEN_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
elif [[ github.event_name == 'workflow_dispatch' ]]; then # Manual Trigger
LATEST_RELEASE=$(jq -r '.assets[] | select(.name | contains("arm64") and contains("forkRelease.apk")) | .browser_download_url' < <(curl -s https://api.github.com/repos/fork-maintainers/iceraven-browser/releases/latest))
ICERAVEN_VERSION=$(echo $LATEST_RELEASE | sed -E 's/.*iceraven-(.*)-browser.*/\1/')
echo "ICERAVEN_VERSION=$ICERAVEN_VERSION" >> $GITHUB_OUTPUT
echo $LATEST_RELEASE # Print the latest release URL for debugging
else # Scheduled run, check for new release
LATEST_RELEASE=$(jq -r '.assets[] | select(.name | contains("arm64") and contains("forkRelease.apk")) | .browser_download_url' < <(curl -s https://api.github.com/repos/fork-maintainers/iceraven-browser/releases/latest))
CURRENT_VERSION=$(jq -r '.tag_name' < <(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest))
ICERAVEN_VERSION=$(echo $LATEST_RELEASE | sed -E 's/.*iceraven-(.*)-browser.*/\1/')
echo "ICERAVEN_VERSION=$ICERAVEN_VERSION" >> $GITHUB_OUTPUT
if [[ "$ICERAVEN_VERSION" == "$CURRENT_VERSION" ]]; then
echo "No new IceRaven release found. Skipping."
exit 0
fi
fi
echo "LATEST_RELEASE=$ASSET_URL" >> $GITHUB_OUTPUT
echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_OUTPUT
- name: Download Latest APK
run: wget -q "${{ steps.get_release.outputs.LATEST_RELEASE }}" -O iceraven.apk
run: |
wget -q "${{ steps.get_release.outputs.LATEST_RELEASE }}" -O iceraven.apk
- name: Run Build Script
run: bash build.sh
- name: Sign APK
Expand All @@ -54,18 +65,18 @@ jobs:
path: iceraven-patched-signed.apk
- name: Create Release (if new version)
id: create_release
if: github.event_name == 'release' # Only create a release automatically for new upstream releases
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # Or ${{ github.token }} if in original repo
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # Use PAT if in a fork
with:
tag_name: iceraven-dark-${{ steps.get_release.outputs.ICERAVEN_VERSION }}
files: iceraven-patched-signed.apk
- name: Get latest release info
id: latest_release
if: steps.create_release.outcome == 'success' # Get the latest release info if a release is successfully created
if: steps.create_release.outcome == 'success'
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # Or ${{ github.token }} if in original repo
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # Use PAT if in fork
with:
latest: true

0 comments on commit dffe89c

Please sign in to comment.