Skip to content

Check for new release and build Zen Browser #5

Check for new release and build Zen Browser

Check for new release and build Zen Browser #5

name: Check for new release and build Zen Browser
on:
schedule:
- cron: '0 0 * * *' # Run daily at midnight UTC
workflow_dispatch: # Allow manual runs
permissions:
contents: write
packages: write
jobs:
check-for-new-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # Get all tags
- name: Get the latest release from Zen Browser
id: get_latest_release
run: |
response=$(curl -sL -w "%{http_code}" \
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
https://api.github.com/repos/zen-browser/desktop/releases/latest -o response.json)
if [ "$response" != "200" ]; then
echo "Error: Failed to fetch latest release (HTTP $response)"
exit 1
fi
tag_name=$(jq -r '.tag_name' response.json)
if [ -z "$tag_name" ] || [ "$tag_name" = "null" ]; then
echo "Error: Could not parse tag name from response"
exit 1
fi
echo "TAG_NAME=$tag_name" >> $GITHUB_ENV
echo "Latest version: $tag_name"
- name: Check if the release exists locally
id: check_local_tag
run: |
if git rev-parse "refs/tags/${{ env.TAG_NAME }}" >/dev/null 2>&1; then
echo "SHOULD_BUILD=false" >> $GITHUB_ENV
echo "Release ${{ env.TAG_NAME }} already exists locally. Skipping build."
else
echo "SHOULD_BUILD=true" >> $GITHUB_ENV
echo "No matching release found. Proceeding with build."
fi
- name: Set up build environment
if: env.SHOULD_BUILD == 'true'
run: |
sudo apt-get update
sudo apt-get install -y zip unzip
- name: Grant execution permissions to build script
if: env.SHOULD_BUILD == 'true'
run: chmod +x ./zenmake_for_dev.sh
- name: Run the build script
if: env.SHOULD_BUILD == 'true'
run: ./zenmake_for_dev.sh
- name: Verify build artifacts
if: env.SHOULD_BUILD == 'true'
run: |
for file in zen-linux-portable.zip zen-windows-portable.zip zen-portable.zip; do
if [ ! -f "$file" ]; then
echo "Error: Build artifact $file is missing"
exit 1
fi
done
- name: Create GitHub Release
if: env.SHOULD_BUILD == 'true'
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
echo "Creating release ${{ env.TAG_NAME }}..."
if ! gh release create "${{ env.TAG_NAME }}" \
zen-linux-portable.zip \
zen-windows-portable.zip \
zen-portable.zip \
--title "Zen Portable ${{ env.TAG_NAME }}" \
--notes "Automated build for release ${{ env.TAG_NAME }}" \
--repo ${{ github.repository }}; then
echo "Error: Failed to create release"
exit 1
fi