-
Notifications
You must be signed in to change notification settings - Fork 0
Add automated release build system #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
63c4886
Add automated release build system.
nchapman c51b8f0
Undo build changes for rg35xxplus.
nchapman 86c6aa6
Use proper version numbers in dev and release.
nchapman 092375d
Simplify 7z usage in build and release.
nchapman b5c8310
Review fixes.
nchapman 423f5a3
Add release convenience methods.
nchapman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: "Dry run (build but skip release)" | ||
| type: boolean | ||
| default: true | ||
|
|
||
| permissions: | ||
| attestations: write | ||
| contents: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: release-${{ github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build-and-release: | ||
| name: Build and Release | ||
| runs-on: sprinters:aws:ubuntu-24.04-arm:c7gd.xlarge | ||
| timeout-minutes: 120 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y jq rsync 7zip | ||
|
|
||
| - name: Build all platforms | ||
| run: make all | ||
| env: | ||
| CI_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
|
|
||
| - name: Verify build artifacts | ||
| run: | | ||
| if ! ls releases/*.zip 1>/dev/null 2>&1; then | ||
| echo "Error: No release artifacts found in releases/" | ||
| exit 1 | ||
| fi | ||
| echo "Found artifacts:" | ||
| ls -la releases/*.zip | ||
|
|
||
| - name: Generate checksums | ||
| run: | | ||
| cd releases | ||
| sha256sum *.zip > SHA256SUMS | ||
| cat SHA256SUMS | ||
|
|
||
| - name: Get version | ||
| id: version | ||
| run: | | ||
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | ||
| echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "version=dev-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Attest build provenance | ||
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | ||
| uses: actions/attest-build-provenance@v3 | ||
| with: | ||
| subject-path: releases/*.zip | ||
|
|
||
| - name: Upload build artifacts | ||
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }} | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: release-${{ steps.version.outputs.version }} | ||
| path: releases/*.zip | ||
| retention-days: 7 | ||
|
|
||
| - name: Create GitHub Release | ||
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| name: LessUI ${{ steps.version.outputs.version }} | ||
| files: | | ||
| releases/*.zip | ||
| releases/SHA256SUMS | ||
| generate_release_notes: true | ||
| make_latest: "true" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| v0.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # Usage: ./scripts/release.sh [patch|minor|major] | ||
| # | ||
| # This script automates the git-flow release process: | ||
| # 1. Computes next version from latest tag | ||
| # 2. Prompts for confirmation | ||
| # 3. Creates git-flow release branch | ||
| # 4. Bumps VERSION file | ||
| # 5. Finishes release (merges to main and develop) | ||
| # 6. Pushes everything including tags | ||
| # | ||
| # After push, GitHub Actions will build and publish the release. | ||
|
|
||
| TYPE="${1:-patch}" | ||
|
|
||
| # Check prerequisites | ||
| if ! git flow version &>/dev/null; then | ||
| echo "Error: git-flow is not installed" | ||
| echo "Install with: brew install git-flow-avh" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! git config --get gitflow.branch.master &>/dev/null; then | ||
| echo "Error: git-flow not initialized in this repository" | ||
| echo "Run: git flow init" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! "$TYPE" =~ ^(patch|minor|major)$ ]]; then | ||
| echo "Usage: $0 [patch|minor|major]" | ||
| echo "" | ||
| echo " patch - Bug fixes, minor changes (v1.0.0 → v1.0.1)" | ||
| echo " minor - New features, backwards compatible (v1.0.1 → v1.1.0)" | ||
| echo " major - Breaking changes (v1.1.0 → v2.0.0)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Get latest tag | ||
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | ||
| echo "Current version: $LATEST_TAG" | ||
|
|
||
| # Parse version components | ||
| VERSION="${LATEST_TAG#v}" | ||
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | ||
|
|
||
nchapman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Compute next version | ||
| case "$TYPE" in | ||
| major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; | ||
| minor) MINOR=$((MINOR + 1)); PATCH=0 ;; | ||
| patch) PATCH=$((PATCH + 1)) ;; | ||
| esac | ||
|
|
||
| NEXT_VERSION="v${MAJOR}.${MINOR}.${PATCH}" | ||
| echo "Next version: $NEXT_VERSION" | ||
| echo "" | ||
|
|
||
| # Confirm | ||
| read -p "Proceed with release $NEXT_VERSION? [y/N] " -n 1 -r | ||
| echo | ||
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||
| echo "Aborted." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Ensure we're on develop | ||
| CURRENT_BRANCH=$(git branch --show-current) | ||
| if [ "$CURRENT_BRANCH" != "develop" ]; then | ||
| echo "Error: Must be on develop branch (currently on $CURRENT_BRANCH)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Ensure develop is up to date with remote | ||
| echo "Checking remote sync..." | ||
| git fetch origin develop --quiet | ||
| LOCAL=$(git rev-parse develop) | ||
| REMOTE=$(git rev-parse origin/develop) | ||
| if [ "$LOCAL" != "$REMOTE" ]; then | ||
| echo "Error: Local develop is not in sync with origin/develop" | ||
| echo " Local: $LOCAL" | ||
| echo " Remote: $REMOTE" | ||
| echo "Please pull or push as needed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Ensure working directory is clean | ||
| if ! git diff-index --quiet HEAD --; then | ||
| echo "Error: Working directory has uncommitted changes" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Get the main branch name from git-flow config | ||
| MAIN_BRANCH=$(git config --get gitflow.branch.master) | ||
| if [ -z "$MAIN_BRANCH" ]; then | ||
| echo "Error: Could not determine main branch from git-flow config" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Ensure main branch exists and is in sync with remote | ||
| echo "Checking $MAIN_BRANCH branch..." | ||
| git fetch origin "$MAIN_BRANCH" --quiet | ||
| if ! git rev-parse "$MAIN_BRANCH" &>/dev/null; then | ||
| echo "Error: Branch '$MAIN_BRANCH' does not exist locally" | ||
| exit 1 | ||
| fi | ||
| MAIN_LOCAL=$(git rev-parse "$MAIN_BRANCH") | ||
| MAIN_REMOTE=$(git rev-parse "origin/$MAIN_BRANCH" 2>/dev/null) || true | ||
| if [ -n "$MAIN_REMOTE" ] && [ "$MAIN_LOCAL" != "$MAIN_REMOTE" ]; then | ||
| echo "Error: Local $MAIN_BRANCH is not in sync with origin/$MAIN_BRANCH" | ||
| echo " Local: $MAIN_LOCAL" | ||
| echo " Remote: $MAIN_REMOTE" | ||
| echo "Please pull or push as needed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Cleanup function to handle failures after release branch is created | ||
| cleanup_release() { | ||
| echo "" | ||
| echo "Error: Release failed. Cleaning up..." | ||
| echo "You may need to manually clean up with:" | ||
| echo " git flow release delete $NEXT_VERSION" | ||
| echo " git checkout develop" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Start release | ||
| echo "" | ||
| echo "Starting release $NEXT_VERSION..." | ||
| git flow release start "$NEXT_VERSION" | ||
|
|
||
| # Set trap to handle failures after release branch is created | ||
| trap cleanup_release ERR | ||
|
|
||
| # Update VERSION file | ||
| echo "$NEXT_VERSION" > VERSION | ||
nchapman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| git add VERSION | ||
| git commit -m "Bump version to $NEXT_VERSION" | ||
|
|
||
| # Finish release (merges to main and develop, creates tag) | ||
| # Use GIT_MERGE_AUTOEDIT=no to avoid editor prompts | ||
| export GIT_MERGE_AUTOEDIT=no | ||
| git flow release finish -m "$NEXT_VERSION" "$NEXT_VERSION" | ||
nchapman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Clear trap after successful finish | ||
| trap - ERR | ||
|
|
||
| # Push everything | ||
| echo "" | ||
| echo "Pushing to origin..." | ||
| git push origin "$MAIN_BRANCH" develop --tags | ||
|
|
||
| # Get repository URL from git remote | ||
| REPO_URL=$(git remote get-url origin | sed -E 's/.*github.com[:\/](.*)\.git/\1/' | sed 's/\.git$//') | ||
|
|
||
| echo "" | ||
| echo "Release $NEXT_VERSION complete!" | ||
| echo "GitHub Actions will now build and publish the release." | ||
| echo "" | ||
| echo "Monitor the build at:" | ||
| echo " https://github.com/${REPO_URL}/actions" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # rg35xx | ||
| ARCH = -march=armv8-a -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 | ||
| ARCH = -marm -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 | ||
| LIBS = -flto | ||
| SDL = SDL2 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.