diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 19bf096..2191536 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -4,10 +4,13 @@ on: push: branches: - main + - develop + - release-candidate permissions: contents: write packages: write + pull-requests: read env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true @@ -18,6 +21,8 @@ jobs: outputs: version: ${{ steps.version.outputs.new_version }} should_release: ${{ steps.version.outputs.should_release }} + is_prerelease: ${{ steps.version.outputs.is_prerelease }} + release_channel: ${{ steps.version.outputs.release_channel }} steps: - uses: actions/checkout@v4 with: @@ -45,23 +50,83 @@ jobs: - name: Generate version id: version + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # Get last tag - LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") - echo "Last tag: $LAST_TAG" + BRANCH="${GITHUB_REF_NAME}" + LAST_STABLE=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1) + if [ -z "$LAST_STABLE" ]; then + LAST_STABLE="v0.0.0" + fi + + VERSION=${LAST_STABLE#v} + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f2) + PATCH=$(echo "$VERSION" | cut -d. -f3) + + BUMP="patch" + IS_PRERELEASE="true" + CHANNEL="alpha" + + if [ "$BRANCH" = "develop" ]; then + LAST_ALPHA=$(git tag -l "v${MAJOR}.${MINOR}.${PATCH}.alpha.*" | grep -E "^v${MAJOR}\.${MINOR}\.${PATCH}\.alpha\.[0-9]+$" | sort -V | tail -n1) + if [ -n "$LAST_ALPHA" ]; then + ALPHA_N=${LAST_ALPHA##*.} + ALPHA_N=$((ALPHA_N + 1)) + else + ALPHA_N=1 + fi + NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}.alpha.${ALPHA_N}" + CHANNEL="alpha" + IS_PRERELEASE="true" + elif [ "$BRANCH" = "release-candidate" ]; then + NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}.beta.${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}.${GITHUB_RUN_ID}" + CHANNEL="beta" + IS_PRERELEASE="true" + else + PR_NUMBER=$(gh api "repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls" --jq '.[0].number' 2>/dev/null || true) - # Parse version - VERSION=${LAST_TAG#v} - MAJOR=$(echo $VERSION | cut -d. -f1) - MINOR=$(echo $VERSION | cut -d. -f2) - PATCH=$(echo $VERSION | cut -d. -f3) + if [ -z "$PR_NUMBER" ]; then + echo "ERROR: Could not find PR associated with commit ${GITHUB_SHA} on main." + echo "Only merges from release-candidate with bump label are allowed." + exit 1 + fi - # Increment patch version - PATCH=$((PATCH + 1)) - NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" + LABELS=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/labels" --jq '.[].name' 2>/dev/null || true) + if echo "$LABELS" | grep -Eq '^(major|semver:major)$'; then + BUMP="major" + elif echo "$LABELS" | grep -Eq '^(minor|semver:minor)$'; then + BUMP="minor" + elif echo "$LABELS" | grep -Eq '^(patch|semver:patch)$'; then + BUMP="patch" + else + echo "ERROR: PR #${PR_NUMBER} is missing bump label (major/minor/patch or semver:major/minor/patch)." + exit 1 + fi + if [ "$BUMP" = "major" ]; then + MAJOR=$((MAJOR + 1)) + MINOR=0 + PATCH=0 + elif [ "$BUMP" = "minor" ]; then + MINOR=$((MINOR + 1)) + PATCH=0 + else + PATCH=$((PATCH + 1)) + fi + + NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" + CHANNEL="stable" + IS_PRERELEASE="false" + fi + + echo "Branch: $BRANCH" + echo "Channel: $CHANNEL" + echo "Last stable: $LAST_STABLE" echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT echo "should_release=true" >> $GITHUB_OUTPUT + echo "is_prerelease=${IS_PRERELEASE}" >> $GITHUB_OUTPUT + echo "release_channel=${CHANNEL}" >> $GITHUB_OUTPUT echo "New version: $NEW_VERSION" - name: Upload build artifacts @@ -95,10 +160,14 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | VERSION="${{ needs.build.outputs.version }}" + IS_PRERELEASE="${{ needs.build.outputs.is_prerelease }}" + CHANNEL="${{ needs.build.outputs.release_channel }}" NOTES=$(cat <<'EOF' ## Changelog - Build date: ${{ github.event.head_commit.timestamp }} - Commit: ${{ github.sha }} + - Branch: ${{ github.ref_name }} + - Channel: ${{ needs.build.outputs.release_channel }} ### Assets - **wallpaper**: Executável do aplicativo @@ -108,7 +177,17 @@ jobs: ) if ! gh release view "$VERSION" >/dev/null 2>&1; then - gh release create "$VERSION" --title "Release $VERSION" --notes "$NOTES" + if [ "$IS_PRERELEASE" = "true" ]; then + gh release create "$VERSION" --title "Release $VERSION" --notes "$NOTES" --prerelease + else + gh release create "$VERSION" --title "Release $VERSION" --notes "$NOTES" + fi + else + if [ "$IS_PRERELEASE" = "true" ]; then + gh release edit "$VERSION" --prerelease --title "Release $VERSION" --notes "$NOTES" + else + gh release edit "$VERSION" --latest --title "Release $VERSION" --notes "$NOTES" + fi fi ASSETS=() diff --git a/.github/workflows/main-pr-guard.yml b/.github/workflows/main-pr-guard.yml new file mode 100644 index 0000000..07c9577 --- /dev/null +++ b/.github/workflows/main-pr-guard.yml @@ -0,0 +1,50 @@ +name: Main PR Guard + +on: + pull_request: + branches: + - main + types: + - opened + - synchronize + - reopened + - labeled + - unlabeled + - edited + +permissions: + contents: read + pull-requests: read + +jobs: + guard: + runs-on: ubuntu-latest + steps: + - name: Enforce source branch and semver label + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + const headRef = pr.head.ref; + const allowedHeadRef = 'release-candidate'; + + if (headRef !== allowedHeadRef) { + core.setFailed(`PRs to main must come from '${allowedHeadRef}', got '${headRef}'.`); + return; + } + + const labelNames = (pr.labels || []).map((l) => l.name); + const allowed = new Set(['major', 'minor', 'patch', 'semver:major', 'semver:minor', 'semver:patch']); + const matches = labelNames.filter((name) => allowed.has(name)); + + if (matches.length === 0) { + core.setFailed('Missing release bump label on PR. Add one of: major, minor, patch (or semver:major|minor|patch).'); + return; + } + + if (matches.length > 1) { + core.setFailed(`Use only one bump label. Found: ${matches.join(', ')}`); + return; + } + + core.info(`PR guard OK. Source: ${headRef}, bump label: ${matches[0]}`); diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index fadb655..461481f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -4,9 +4,11 @@ on: pull_request: branches: - main + - develop push: branches: - develop + - release-candidate jobs: build: diff --git a/README.md b/README.md index c5a188e..a42b2f4 100644 --- a/README.md +++ b/README.md @@ -303,13 +303,45 @@ This project is licensed under the MIT License. See the LICENSE file for details ## 🤝 Contributing -Contributions are welcome! Please: +Contributions are welcome. This project uses a strict release flow: + +1. Create your feature/fix branch from `develop` +2. Open a PR to `develop` +3. After validation, changes are promoted to `release-candidate` +4. Only PRs from `release-candidate` are allowed into `main` + +### Release Flow Rules + +- Push to `develop` generates an **alpha** pre-release version: + - Format: `vX.Y.Z.alpha.N` +- Push to `release-candidate` generates a **beta** pre-release version: + - Format: `vX.Y.Z.beta.A.B.C` +- Push/merge to `main` generates a **stable** release version: + - Format: `vX.Y.Z` + +### Main Merge Policy + +- Target branch `main` only accepts PRs coming from `release-candidate` +- PR must contain exactly one bump label: + - `patch` or `semver:patch` + - `minor` or `semver:minor` + - `major` or `semver:major` + +### Version Bump Semantics (main) + +- `patch`: `X.Y.Z` -> `X.Y.(Z+1)` +- `minor`: `X.Y.Z` -> `X.(Y+1).0` +- `major`: `X.Y.Z` -> `(X+1).0.0` + +### Suggested Contribution Steps 1. Fork the repository -2. Create a branch for your feature (`git checkout -b feature/MyFeature`) +2. Create a branch from `develop` (`git checkout -b feature/MyFeature develop`) 3. Commit your changes (`git commit -am 'Add some AmazingFeature'`) -4. Push to the branch (`git push origin feature/MyFeature`) -5. Open a Pull Request +4. Push your branch (`git push origin feature/MyFeature`) +5. Open a PR to `develop` +6. Promote tested changes to `release-candidate` +7. Open PR from `release-candidate` to `main` with one required bump label ### Development Guidelines diff --git a/templates/aurora-waves.html b/templates/aurora-waves.html new file mode 100644 index 0000000..7e533e1 --- /dev/null +++ b/templates/aurora-waves.html @@ -0,0 +1,68 @@ + + + + + + Aurora Waves + + + + + + + diff --git a/templates/digital-clock.html b/templates/digital-clock.html new file mode 100644 index 0000000..2ea2c0a --- /dev/null +++ b/templates/digital-clock.html @@ -0,0 +1,105 @@ + + + + + + Digital Clock + + + +
+
00:00:00
+
---
+
+ + + + diff --git a/templates/doom-fire.html b/templates/doom-fire.html new file mode 100644 index 0000000..7d2a764 --- /dev/null +++ b/templates/doom-fire.html @@ -0,0 +1,134 @@ + + + + + + Doom Fire + + + + + + + diff --git a/templates/matrix-rain.html b/templates/matrix-rain.html new file mode 100644 index 0000000..75b86c8 --- /dev/null +++ b/templates/matrix-rain.html @@ -0,0 +1,72 @@ + + + + + + Matrix Rain + + + + + + + diff --git a/templates/particles-network.html b/templates/particles-network.html new file mode 100644 index 0000000..63fd2f3 --- /dev/null +++ b/templates/particles-network.html @@ -0,0 +1,94 @@ + + + + + + Particles Network + + + + + + + diff --git a/templates/starfield.html b/templates/starfield.html new file mode 100644 index 0000000..9d8a270 --- /dev/null +++ b/templates/starfield.html @@ -0,0 +1,88 @@ + + + + + + Starfield + + + + + + +