Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/actions/linting/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Linting"
description: "Reusable action for running Flutter and Dart linting"
inputs:
working_directory:
description: The working directory for Dart analysis.
required: true
default: .

runs:
using: "composite"
steps:
- name: melos analyze
shell: bash
run: melos analyze

- name: Analyzing code with Dart analyzer
shell: bash
run: dart analyze --fatal-infos

- name: Run Dart analysis
uses: zgosalvez/github-actions-analyze-dart@v3
with:
working-directory: ${{ inputs.working_directory }}
117 changes: 117 additions & 0 deletions .github/actions/version-bump/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: "Version Bumper"
description: "Bumps semantic version based on PR labels and increments build number."

inputs:
github_token:
description: "Github Token"
required: true
pubspec_file:
description: "Path to pubspec file"
required: true

outputs:
new_version:
description: "New semantic version generated"
value: ${{ steps.output.outputs.new_version }}

runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install GitHub CLI (gh)
shell: bash
run: |
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y

# - name: Set up Git
# shell: bash
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# # git remote set-url origin https://x-access-token:${{ inputs.github-token }}@github.com/ZanderCowboy/multichoice.git

- name: Run version bump logic
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
PUBSPEC_FILE: ${{ inputs.pubspec_file }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
LABELS=$(gh pr view "$PR_NUMBER" --json labels -q '.labels[].name')

BUMP_TYPE=""
if echo "$LABELS" | grep -qi "major"; then
BUMP_TYPE="major"
elif echo "$LABELS" | grep -qi "minor"; then
BUMP_TYPE="minor"
elif echo "$LABELS" | grep -qi "patch"; then
BUMP_TYPE="patch"
else
echo "No valid bump label found (major/minor/patch). Bumping build number."
# exit 0
fi

echo "Bump type identified: $BUMP_TYPE"

git fetch --tags
# LATEST_TAG=$(git tag -l 'v*.*.*' --sort=-version:refname | head -n1)
LATEST_TAG=${LATEST_TAG:-v0.4.0+123}
echo "LATEST_TAG=$LATEST_TAG" >> "$GITHUB_ENV"
echo "LATEST_TAG=$LATEST_TAG"

SEMVER=${LATEST_TAG#v}
echo "Current version: $SEMVER"

MAJOR=$(echo "$SEMVER" | cut -d '.' -f 1)
MINOR=$(echo "$SEMVER" | cut -d '.' -f 2)
PATCH=$(echo "$SEMVER" | cut -d '.' -f 3 | cut -d '+' -f 1)
BUILD=$(echo "$SEMVER" | grep '+' | cut -d '+' -f 2)

BUILD=${BUILD:-1}

echo "Bump type:"

case $BUMP_TYPE in
major)
MAJOR=$((MAJOR++))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR++))
PATCH=0
;;
patch)
PATCH=$((PATCH++))
;;
esac

NEW_SEMVER="$MAJOR.$MINOR.$PATCH"
NEW_BUILD=$((BUILD++))

echo "New version: $NEW_SEMVER"
NEW_VERSION="${NEW_SEMVER}+${NEW_BUILD}"
echo "New version with build number: $NEW_VERSION"

sed -i -E "s/^version:[[:space:]]*.*/version: $NEW_VERSION/" "${{ inputs.pubspec_file }}"

# git add "${{ inputs.pubspec_file }}"
# git commit -m "chore: bump version to $NEW_VERSION"
# git push origin HEAD

# git tag "v${NEW_SEMVER}"
# git push origin "v${NEW_SEMVER}"

echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "new_version=$NEW_VERSION" >> "$GITHUB_ENV"
59 changes: 59 additions & 0 deletions .github/actions/version-bump/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

LABELS=$(gh pr view "$PR_NUMBER" --json labels -q '.labels[].name')

BUMP_TYPE=""
if echo "$LABELS" | grep -qi "major"; then
BUMP_TYPE="major"
elif echo "$LABELS" | grep -qi "minor"; then
BUMP_TYPE="minor"
elif echo "$LABELS" | grep -qi "patch"; then
BUMP_TYPE="patch"
fi

if [ -z "$BUMP_TYPE" ]; then
echo "No version bump label found (major/minor/patch). Exiting."
exit 0
fi

# Extract current version from pubspec.yaml
CURRENT_VERSION=$(grep '^version:' "$VERSION_FILE" | sed 's/version: //')

SEMVER=$(echo "$CURRENT_VERSION" | cut -d '+' -f 1)
BUILD_NUM=$(echo "$CURRENT_VERSION" | cut -d '+' -f 2)

MAJOR=$(echo "$SEMVER" | cut -d '.' -f 1)
MINOR=$(echo "$SEMVER" | cut -d '.' -f 2)
PATCH=$(echo "$SEMVER" | cut -d '.' -f 3)

case $BUMP_TYPE in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac

# Increment build number always
BUILD_NUM=$((BUILD_NUM + 1))

NEW_VERSION="$MAJOR.$MINOR.$PATCH+$BUILD_NUM"

# Update pubspec.yaml
sed -i -E "s/^version: .*/version: $NEW_VERSION/" "$VERSION_FILE"

# Commit changes
git add "$VERSION_FILE"
git commit -m "chore: bump version to $NEW_VERSION"
git push origin HEAD

echo "Version bumped to $NEW_VERSION"
2 changes: 1 addition & 1 deletion .github/workflows/_build-android-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: melos coverage:core

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: packages/core/coverage/lcov.info
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/build_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Test, Analyze, Build
on:
push:
branches:
- "develop"
pull_request:
branches:
- "develop"
types:
- "opened"
- "synchronize"
- "reopened"
- "ready_for_review"
# push:
# branches:
# - "develop"
# pull_request:
# branches:
# - "develop"
# types:
# - "opened"
# - "synchronize"
# - "reopened"
# - "ready_for_review"

workflow_dispatch:

Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/develop-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
name: Develop Workflow

on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
lint-test-report:
name: Develop - Lint, Test, Report
runs-on: ubuntu-latest

permissions:
contents: read
packages: read
statuses: write
pull-requests: read

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

###########################################
# SETUP FLUTTER AND JAVA
###########################################
- name: Set up Flutter and Java
uses: ./.github/actions/setup-java-flutter

###########################################
# LINTING
###########################################
# - name: Linting
# if: ${{ github.event.pull_request.merged == false }}
# uses: ./.github/actions/linting
# with:
# working_directory: "${{ github.workspace }}/"

###########################################
# TESTS AND COVERAGE
###########################################
# - name: melos coverage:core
# if: ${{ github.event.pull_request.merged == false }}
# run: melos coverage:core

# - name: Upload coverage to Codecov
# if: ${{ github.event.pull_request.merged == false }}
# uses: codecov/codecov-action@v4 # For local testing, use codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: packages/core/coverage/lcov.info
# fail_ci_if_error: true

###########################################
# VERSION BUMP
###########################################
- name: Bump version based on PR labels
uses: ./.github/actions/version-bump
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pubspec_file: "apps/multichoice/pubspec.yaml"

###########################################
# BUILD
###########################################

###########################################
# FIREBASE UPLOAD
###########################################

###########################################
# COMMIT NEW VERSION
###########################################
# - name: Auto commit new pubspec version
# id: auto-commit-action
# uses: stefanzweifel/git-auto-commit-action@v5
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# commit_message: "Bump pubspec version to ${{ env.new_version }}"
# file_pattern: "apps/multichoice/pubspec.yaml"
# disable_globbing: true
2 changes: 1 addition & 1 deletion apps/multichoice/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: multichoice
description: "The application for the Multichoice repo"
publish_to: "none"

version: 0.3.0+156
version: 0.3.0+158

environment:
sdk: ">=3.3.0 <4.0.0"
Expand Down
Loading