workflow_dispatch only works from branches, not tags. Add tag input so manual runs specify the version explicitly via inputs.tag, falling back to github.ref_name for automatic tag-push runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
139 lines
4.6 KiB
YAML
139 lines
4.6 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Release tag (e.g. v1.0.10)'
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: read
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build UI bundle
|
|
run: |
|
|
npx esbuild src/ui/main.jsx --bundle --format=iife --jsx=automatic \
|
|
--define:process.env.NODE_ENV=\"production\" --outfile=assets/app-ui.bundle
|
|
|
|
- name: Build Bare bundle
|
|
run: node_modules/.bin/bare-pack --linked src/bare.js -o assets/bare-universal.bundle
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'temurin'
|
|
|
|
- name: Cache Gradle
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: gradle-${{ hashFiles('android/**/*.gradle*', 'android/gradle/wrapper/gradle-wrapper.properties') }}
|
|
restore-keys: gradle-
|
|
|
|
- name: Set up Android SDK
|
|
uses: android-actions/setup-android@v3
|
|
|
|
- name: Decode keystore
|
|
run: |
|
|
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/pearcal-release.keystore
|
|
|
|
- name: Build signed release APK
|
|
env:
|
|
KEYSTORE_FILE: pearcal-release.keystore
|
|
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
|
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
|
|
run: |
|
|
APP_VERSION="${RELEASE_TAG#v}"
|
|
[ -z "$APP_VERSION" ] || [ "$APP_VERSION" = "master" ] && APP_VERSION="1.0.0"
|
|
export APP_VERSION
|
|
cd android && ./gradlew assembleRelease
|
|
|
|
- name: Rename APK with version
|
|
env:
|
|
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
|
|
run: |
|
|
cp android/app/build/outputs/apk/release/app-release.apk pearcal-${RELEASE_TAG}.apk
|
|
|
|
- name: Generate release notes from PR summaries
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
# Get published_at of the most recent release (current tag not yet created)
|
|
PREV_RELEASE_DATE=$(gh api repos/${{ github.repository }}/releases \
|
|
--jq '[.[] | select(.draft == false)] | .[0].published_at // ""')
|
|
|
|
NOTES="## What's Changed\n\n"
|
|
|
|
if [ -z "$PREV_RELEASE_DATE" ]; then
|
|
NOTES="${NOTES}Initial release.\n"
|
|
else
|
|
# Fetch merged PRs and filter to those merged after the previous release
|
|
ALL_PRS=$(gh pr list --state merged --limit 100 \
|
|
--json number,title,body,mergedAt)
|
|
FILTERED=$(echo "$ALL_PRS" | jq --arg since "$PREV_RELEASE_DATE" \
|
|
'[.[] | select(.mergedAt > $since)]')
|
|
|
|
PR_COUNT=$(echo "$FILTERED" | jq 'length')
|
|
|
|
if [ "$PR_COUNT" = "0" ]; then
|
|
NOTES="${NOTES}No merged PRs since last release.\n"
|
|
else
|
|
while IFS= read -r pr_json; do
|
|
TITLE=$(echo "$pr_json" | jq -r '.title')
|
|
BODY=$(echo "$pr_json" | jq -r '.body // ""')
|
|
SUMMARY=$(printf '%s' "$BODY" | awk '/^## Summary/{f=1;next} /^## /{if(f)exit} f && /\S/{print}')
|
|
NOTES="${NOTES}### ${TITLE}\n"
|
|
[ -n "$SUMMARY" ] && NOTES="${NOTES}${SUMMARY}\n"
|
|
NOTES="${NOTES}\n"
|
|
done < <(echo "$FILTERED" | jq -c '.[]')
|
|
fi
|
|
fi
|
|
|
|
printf "%b" "$NOTES" > release_notes.md
|
|
echo "--- Release notes ---"
|
|
cat release_notes.md
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ inputs.tag || github.ref_name }}
|
|
files: pearcal-${{ inputs.tag || github.ref_name }}.apk
|
|
body_path: release_notes.md
|
|
|
|
- name: Install zsp (Zapstore publisher)
|
|
run: |
|
|
ZSP_URL=$(curl -s https://api.github.com/repos/zapstore/zsp/releases/latest \
|
|
| grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4)
|
|
curl -sL "$ZSP_URL" -o /usr/local/bin/zsp
|
|
chmod +x /usr/local/bin/zsp
|
|
|
|
- name: Publish to Zapstore
|
|
env:
|
|
SIGN_WITH: ${{ secrets.ZAPSTORE_NSEC }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: zsp publish -y zapstore.yaml
|