diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 12d8f429d0..e133a5e6d9 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -466,15 +466,15 @@ jobs: echo "Found Jira ticket: $JIRA_TICKET" - # Validate NEXT_RELEASE_VERSION exists and exactly two digits, dot, two digits + # Validate NEXT_RELEASE_VERSION format if [ -z "$NEXT_RELEASE_VERSION" ]; then echo "ERROR: NEXT_RELEASE_VERSION variable is not set" exit 1 fi - if [[ ! "$NEXT_RELEASE_VERSION" =~ ^[0-9]{2}\.[0-9]{2}$ ]]; then + if [[ ! "$NEXT_RELEASE_VERSION" =~ ^[0-9]{2}\.[0-9]{2}(\.[0-9]+)?$ ]]; then echo "ERROR: NEXT_RELEASE_VERSION format is invalid: $NEXT_RELEASE_VERSION" - echo "Expected format: YY.ww (two digits, dot, two digits, e.g., 25.50)" + echo "Expected format: YY.ww[.patch] (e.g., 25.50 or 25.50.1)" exit 1 fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 76548a1185..a294619a64 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,11 @@ on: schedule: - cron: '0 12 * * *' # Daily at 12:00 PM UTC workflow_dispatch: + inputs: + hotfix_version: + description: 'Version stamp for an off-cycle release (e.g. 26.38.1). Still merges stage into main and builds main.' + required: false + type: string env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -485,15 +490,15 @@ jobs: - name: Validate release version env: - NEXT_RELEASE_VERSION: ${{ vars.NEXT_RELEASE_VERSION }} + NEXT_RELEASE_VERSION: ${{ github.event.inputs.hotfix_version || vars.NEXT_RELEASE_VERSION }} run: | if [ -z "$NEXT_RELEASE_VERSION" ]; then echo "ERROR: NEXT_RELEASE_VERSION variable is not set" exit 1 fi - if [[ ! "$NEXT_RELEASE_VERSION" =~ ^[0-9]{2}\.[0-9]{2}$ ]]; then + if [[ ! "$NEXT_RELEASE_VERSION" =~ ^[0-9]{2}\.[0-9]{2}(\.[0-9]+)?$ ]]; then echo "ERROR: NEXT_RELEASE_VERSION format is invalid: $NEXT_RELEASE_VERSION" - echo "Expected format: YY.ww (two digits, dot, two digits, e.g., 25.50)" + echo "Expected format: YY.ww[.patch] (e.g., 25.50 or 25.50.1)" exit 1 fi echo "Validated NEXT_RELEASE_VERSION: $NEXT_RELEASE_VERSION" @@ -505,7 +510,7 @@ jobs: - name: Assemble Release APK env: INCLUDE_LLAMA_ASSETS: "true" - NEXT_RELEASE_VERSION: ${{ vars.NEXT_RELEASE_VERSION }} + NEXT_RELEASE_VERSION: ${{ github.event.inputs.hotfix_version || vars.NEXT_RELEASE_VERSION }} run: | variant_upper=$(echo "${{ matrix.variant }}" | tr '[:lower:]' '[:upper:]') flox activate -d flox/base -- ./gradlew :app:assemble${variant_upper}Release --no-daemon \ diff --git a/.github/workflows/weekly-release.yml b/.github/workflows/weekly-release.yml index 8259cb7cac..9a772c20f7 100644 --- a/.github/workflows/weekly-release.yml +++ b/.github/workflows/weekly-release.yml @@ -2,6 +2,11 @@ name: Weekly release (manual) on: workflow_dispatch: + inputs: + hotfix_version: + description: 'Version for an off-cycle release (e.g. 26.38.1). Publishes the current build under this version instead of the CalVer week.' + required: false + type: string permissions: contents: read @@ -27,12 +32,26 @@ jobs: - name: Compute CalVer version id: compute + env: + HOTFIX_VERSION: ${{ github.event.inputs.hotfix_version }} run: | - VERSION=$(date -u +%g.%V) + if [[ -n "$HOTFIX_VERSION" ]]; then + if [[ ! "$HOTFIX_VERSION" =~ ^[0-9]{2}\.[0-9]{2}(\.[0-9]+)?$ ]]; then + echo "::error::Invalid hotfix version format: $HOTFIX_VERSION" + exit 1 + fi + VERSION="$HOTFIX_VERSION" + else + VERSION=$(date -u +%g.%V) + fi NEXT_VERSION=$(date -u -d "+7 days" +%g.%V) echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "next_version=$NEXT_VERSION" >> "$GITHUB_OUTPUT" - echo "Releasing $VERSION (next will be $NEXT_VERSION)" + if [[ -n "$HOTFIX_VERSION" ]]; then + echo "Releasing hotfix $VERSION (NEXT_RELEASE_VERSION left unchanged)" + else + echo "Releasing $VERSION (next will be $NEXT_VERSION)" + fi - name: Look up previous CalVer tag id: previous @@ -41,7 +60,7 @@ jobs: shell: flox activate -d flox/base -- bash -eo pipefail {0} run: | PREVIOUS_TAG=$(gh release list --json tagName \ - --jq '[.[] | select(.tagName | test("^[0-9]+\\.[0-9]+$"))] | .[0].tagName // ""') + --jq '[.[] | select(.tagName | test("^[0-9]+\\.[0-9]+(\\.[0-9]+)?$"))] | .[0].tagName // ""') echo "previous_tag=$PREVIOUS_TAG" >> "$GITHUB_OUTPUT" echo "Previous CalVer tag: ${PREVIOUS_TAG:-none}" @@ -198,20 +217,20 @@ jobs: exit 0 fi + # A hotfix cut against a superseded release must not steal the "Latest" + # badge from the newer release that is already published. + IS_LATEST=true + if [[ -n "$PREVIOUS_TAG" ]] \ + && [[ "$(printf '%s\n%s\n' "$VERSION" "$PREVIOUS_TAG" | sort -V | tail -n1)" != "$VERSION" ]]; then + IS_LATEST=false + fi + echo "Marking $VERSION as latest: $IS_LATEST (previous tag: ${PREVIOUS_TAG:-none})" + + ARGS=(--target "$GITHUB_SHA" --latest="$IS_LATEST" --title "$VERSION" --generate-notes) if [[ -n "$PREVIOUS_TAG" && "$PREVIOUS_TAG" != "$VERSION" ]]; then - gh release create "$VERSION" \ - --target "$GITHUB_SHA" \ - --latest \ - --title "$VERSION" \ - --generate-notes \ - --notes-start-tag "$PREVIOUS_TAG" - else - gh release create "$VERSION" \ - --target "$GITHUB_SHA" \ - --latest \ - --title "$VERSION" \ - --generate-notes + ARGS+=(--notes-start-tag "$PREVIOUS_TAG") fi + gh release create "$VERSION" "${ARGS[@]}" upload-r2: needs: [prepare, pull-apk] @@ -294,6 +313,7 @@ jobs: private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} - name: Set NEXT_RELEASE_VERSION repo variable + if: ${{ github.event.inputs.hotfix_version == '' }} env: GH_TOKEN: ${{ steps.app-token.outputs.token }} NEXT_VERSION: ${{ needs.prepare.outputs.next_version }} diff --git a/composite-builds/build-logic/common/src/main/java/com/itsaky/androidide/build/config/ProjectConfig.kt b/composite-builds/build-logic/common/src/main/java/com/itsaky/androidide/build/config/ProjectConfig.kt index 4b6736ff58..c723937eaa 100644 --- a/composite-builds/build-logic/common/src/main/java/com/itsaky/androidide/build/config/ProjectConfig.kt +++ b/composite-builds/build-logic/common/src/main/java/com/itsaky/androidide/build/config/ProjectConfig.kt @@ -108,9 +108,9 @@ val Project.releaseVersion: String .orNull .orEmpty() .trim() - if (raw.isNotEmpty() && !Regex("""^\d{2}\.\d{2}$""").matches(raw)) { + if (raw.isNotEmpty() && !Regex("""^\d{2}\.\d{2}(\.\d+)?$""").matches(raw)) { throw GradleException( - "Invalid next_release_version '$raw'; expected YY.ww (two digits, dot, two digits), e.g. 25.47", + "Invalid next_release_version '$raw'; expected YY.ww with an optional patch, e.g. 25.47 or 25.47.1", ) } return raw