From 2972d385d96b6fb208067174a0a7eeb1d9382dc3 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 19 Mar 2025 23:25:30 +0200 Subject: [PATCH 01/13] Make entrypoint.sh executable --- .github/actions/version-bump/entrypoint.sh | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 .github/actions/version-bump/entrypoint.sh diff --git a/.github/actions/version-bump/entrypoint.sh b/.github/actions/version-bump/entrypoint.sh new file mode 100755 index 00000000..d83a4bd0 --- /dev/null +++ b/.github/actions/version-bump/entrypoint.sh @@ -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" From 5e229d41739f48185176726eeac97b38539263cf Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Wed, 19 Mar 2025 21:46:07 +0000 Subject: [PATCH 02/13] Bump pubspec version to '0.3.0+157' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index ed0ff3dd..1f03e478 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -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+157 environment: sdk: ">=3.3.0 <4.0.0" From 6e988ee93eaa86396d4d3d804e1293bc609e7793 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 20 Mar 2025 00:06:35 +0200 Subject: [PATCH 03/13] add linting and version-bump action and develop-workflow.yml --- .github/actions/linting/action.yml | 23 +++++ .github/actions/version-bump/action.yml | 110 +++++++++++++++++++++++ .github/workflows/_build-android-app.yml | 2 +- .github/workflows/develop-workflow.yml | 74 +++++++++++++++ 4 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 .github/actions/linting/action.yml create mode 100644 .github/actions/version-bump/action.yml create mode 100644 .github/workflows/develop-workflow.yml diff --git a/.github/actions/linting/action.yml b/.github/actions/linting/action.yml new file mode 100644 index 00000000..3605b795 --- /dev/null +++ b/.github/actions/linting/action.yml @@ -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 }} diff --git a/.github/actions/version-bump/action.yml b/.github/actions/version-bump/action.yml new file mode 100644 index 00000000..bd4739f6 --- /dev/null +++ b/.github/actions/version-bump/action.yml @@ -0,0 +1,110 @@ +name: "Version Bumper" +description: "Bumps semantic version based on PR labels and increments build number." + +inputs: + github-token: + description: "GitHub token" + required: true + version-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" + + - name: Run version bump script + shell: bash + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + VERSION_FILE: ${{ inputs.version-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). Exiting." + exit 0 + fi + + echo "Bump type identified: $BUMP_TYPE" + + CURRENT_VERSION=$(grep '^version:' $VERSION_FILE | sed 's/version: //') + echo "Current version: $CURRENT_VERSION" + + SEMVER=$(echo "$CURRENT_VERSION" | cut -d '+' -f 1) + echo "Semantic version: $SEMVER" + BUILD_NUM=$(echo "$CURRENT_VERSION" | cut -d '+' -f 2) + echo "Build number: $BUILD_NUM" + + 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 + + echo "Old build number: $BUILD_NUM" + BUILD_NUM=$(echo "$BUILD_NUM" | tr -d '\r\n[:space:]') + BUILD_NUM=$((BUILD_NUM + 1)) + echo "Build number incremented to: $BUILD_NUM" + + NEW_VERSION="$MAJOR.$MINOR.$PATCH+$BUILD_NUM" + echo "New version: $NEW_VERSION" + echo "new-version=$NEW_VERSION" >> "$GITHUB_OUTPUT" + + sed -i -E "s/^(version:[[:space:]]*).*/\1$NEW_VERSION/" $VERSION_FILE + + - name: Auto commit new pubspec version + id: auto-commit-action + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Bump pubspec version to $NEW_VERSION" + file_pattern: "apps/multichoice/pubspec.*" + disable_globbing: true diff --git a/.github/workflows/_build-android-app.yml b/.github/workflows/_build-android-app.yml index f0b181e3..f6528d10 100644 --- a/.github/workflows/_build-android-app.yml +++ b/.github/workflows/_build-android-app.yml @@ -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 diff --git a/.github/workflows/develop-workflow.yml b/.github/workflows/develop-workflow.yml new file mode 100644 index 00000000..4ce6f0c6 --- /dev/null +++ b/.github/workflows/develop-workflow.yml @@ -0,0 +1,74 @@ +--- +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 }} + version-file: "apps/multichoice/pubspec.yaml" + + ########################################### + # BUILD + ########################################### + + ########################################### + # FIREBASE UPLOAD + ########################################### From af67e8fa55e6b8dc8a82a84d7593eb57221ff8ba Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 20 Mar 2025 00:27:05 +0200 Subject: [PATCH 04/13] fix auto commit issue --- .github/actions/version-bump/action.yml | 19 ++++++------------- .github/workflows/develop-workflow.yml | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/actions/version-bump/action.yml b/.github/actions/version-bump/action.yml index bd4739f6..75955dbe 100644 --- a/.github/actions/version-bump/action.yml +++ b/.github/actions/version-bump/action.yml @@ -34,11 +34,11 @@ runs: && 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" + # - 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" - name: Run version bump script shell: bash @@ -98,13 +98,6 @@ runs: NEW_VERSION="$MAJOR.$MINOR.$PATCH+$BUILD_NUM" echo "New version: $NEW_VERSION" echo "new-version=$NEW_VERSION" >> "$GITHUB_OUTPUT" + echo "new-version=$NEW_VERSION" >> "$GITHUB_ENV" sed -i -E "s/^(version:[[:space:]]*).*/\1$NEW_VERSION/" $VERSION_FILE - - - name: Auto commit new pubspec version - id: auto-commit-action - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "Bump pubspec version to $NEW_VERSION" - file_pattern: "apps/multichoice/pubspec.*" - disable_globbing: true diff --git a/.github/workflows/develop-workflow.yml b/.github/workflows/develop-workflow.yml index 4ce6f0c6..44307d1f 100644 --- a/.github/workflows/develop-workflow.yml +++ b/.github/workflows/develop-workflow.yml @@ -72,3 +72,17 @@ jobs: ########################################### # 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 }} + NEW_VERSION: ${{ env.new_version }} + with: + commit_message: "Bump pubspec version to ${{ NEW_VERSION }}" + file_pattern: "apps/multichoice/pubspec.yaml" + disable_globbing: true From a7a15588fb7c210e9da8a7a3ea8036edca10a828 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 20 Mar 2025 00:29:34 +0200 Subject: [PATCH 05/13] fix error with NEW_VERSION not found --- .github/workflows/develop-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/develop-workflow.yml b/.github/workflows/develop-workflow.yml index 44307d1f..9ac551ad 100644 --- a/.github/workflows/develop-workflow.yml +++ b/.github/workflows/develop-workflow.yml @@ -83,6 +83,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NEW_VERSION: ${{ env.new_version }} with: - commit_message: "Bump pubspec version to ${{ NEW_VERSION }}" + commit_message: "Bump pubspec version to $NEW_VERSION" file_pattern: "apps/multichoice/pubspec.yaml" disable_globbing: true From 9983bd65127f42a4cb3c4bd183bec06ef612e632 Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Wed, 19 Mar 2025 22:37:22 +0000 Subject: [PATCH 06/13] Bump pubspec version to '0.3.0+158' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index 1f03e478..26c61688 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -2,7 +2,7 @@ name: multichoice description: "The application for the Multichoice repo" publish_to: "none" -version: 0.3.0+157 +version: 0.3.0+158 environment: sdk: ">=3.3.0 <4.0.0" From 6833a1616ec9ec2e402fbce61ebe9b36b197e1fb Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 20 Mar 2025 00:52:34 +0200 Subject: [PATCH 07/13] test the use of tags for race conditions --- .github/actions/version-bump/action.yml | 51 ++++++++++++++----------- .github/workflows/build_workflow.yml | 22 +++++------ .github/workflows/develop-workflow.yml | 19 +++++---- 3 files changed, 49 insertions(+), 43 deletions(-) diff --git a/.github/actions/version-bump/action.yml b/.github/actions/version-bump/action.yml index 75955dbe..2cb285a1 100644 --- a/.github/actions/version-bump/action.yml +++ b/.github/actions/version-bump/action.yml @@ -34,13 +34,14 @@ runs: && 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" + - 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:${{ secrets.GITHUB_TOKEN }}@github.com/ZanderCowboy/multichoice.git - - name: Run version bump script + - name: Run version bump logic shell: bash env: GITHUB_TOKEN: ${{ inputs.github-token }} @@ -63,14 +64,16 @@ runs: echo "Bump type identified: $BUMP_TYPE" - CURRENT_VERSION=$(grep '^version:' $VERSION_FILE | sed 's/version: //') - echo "Current version: $CURRENT_VERSION" - - SEMVER=$(echo "$CURRENT_VERSION" | cut -d '+' -f 1) - echo "Semantic version: $SEMVER" - BUILD_NUM=$(echo "$CURRENT_VERSION" | cut -d '+' -f 2) - echo "Build number: $BUILD_NUM" + git fetch --tags + LATEST_TAG=$(git tag --sort=-version:refname 'v*.*.*' | head -n1) + if [ -z "$LATEST_TAG" ]; then + echo "Error: No tags found in the repository." + exit 1 + fi + 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) @@ -90,14 +93,18 @@ runs: ;; esac - echo "Old build number: $BUILD_NUM" - BUILD_NUM=$(echo "$BUILD_NUM" | tr -d '\r\n[:space:]') - BUILD_NUM=$((BUILD_NUM + 1)) - echo "Build number incremented to: $BUILD_NUM" + NEW_SEMVER="$MAJOR.$MINOR.$PATCH" + echo "New version: $NEW_SEMVER" + NEW_VERSION="${NEW_SEMVER}+${{ github.run_number }}" + echo "New version with build number: $NEW_VERSION" - NEW_VERSION="$MAJOR.$MINOR.$PATCH+$BUILD_NUM" - echo "New version: $NEW_VERSION" - echo "new-version=$NEW_VERSION" >> "$GITHUB_OUTPUT" - echo "new-version=$NEW_VERSION" >> "$GITHUB_ENV" + sed -i -E "s/^version:.*/version: $NEW_VERSION/" "${{ inputs.version-file }}" + + git add "${{ inputs.version-file }}" + git commit -m "chore: bump version to $NEW_VERSION" + git push origin HEAD - sed -i -E "s/^(version:[[:space:]]*).*/\1$NEW_VERSION/" $VERSION_FILE + git tag "v${NEW_SEMVER}" + git push origin "v${NEW_SEMVER}" + + echo "new-version=$NEW_VERSION" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/build_workflow.yml b/.github/workflows/build_workflow.yml index baa03540..feda4e2c 100644 --- a/.github/workflows/build_workflow.yml +++ b/.github/workflows/build_workflow.yml @@ -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: diff --git a/.github/workflows/develop-workflow.yml b/.github/workflows/develop-workflow.yml index 9ac551ad..492db7b8 100644 --- a/.github/workflows/develop-workflow.yml +++ b/.github/workflows/develop-workflow.yml @@ -76,13 +76,12 @@ jobs: ########################################### # 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 }} - NEW_VERSION: ${{ env.new_version }} - with: - commit_message: "Bump pubspec version to $NEW_VERSION" - file_pattern: "apps/multichoice/pubspec.yaml" - disable_globbing: true + # - 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 From 53ef61e77bb5fed749cf7a7ed72b85fbd2e3edf6 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 20 Mar 2025 01:01:17 +0200 Subject: [PATCH 08/13] correct secrets issue on action --- .github/actions/version-bump/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/version-bump/action.yml b/.github/actions/version-bump/action.yml index 2cb285a1..59f45e24 100644 --- a/.github/actions/version-bump/action.yml +++ b/.github/actions/version-bump/action.yml @@ -39,7 +39,7 @@ runs: 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:${{ secrets.GITHUB_TOKEN }}@github.com/ZanderCowboy/multichoice.git + # git remote set-url origin https://x-access-token:${{ inputs.github-token }}@github.com/ZanderCowboy/multichoice.git - name: Run version bump logic shell: bash From d2b61a27c5a3611ec155ce85c4930ffafc624cc7 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 20 Mar 2025 01:09:37 +0200 Subject: [PATCH 09/13] fix invalid tag name --- .github/actions/version-bump/action.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/actions/version-bump/action.yml b/.github/actions/version-bump/action.yml index 59f45e24..8caac479 100644 --- a/.github/actions/version-bump/action.yml +++ b/.github/actions/version-bump/action.yml @@ -65,12 +65,10 @@ runs: echo "Bump type identified: $BUMP_TYPE" git fetch --tags - LATEST_TAG=$(git tag --sort=-version:refname 'v*.*.*' | head -n1) - if [ -z "$LATEST_TAG" ]; then - echo "Error: No tags found in the repository." - exit 1 - fi - echo "Latest tag: $LATEST_TAG" + LATEST_TAG=$(git tag -l 'v*.*.*' --sort=-version:refname | head -n1) + LATEST_TAG=${LATEST_TAG:-v0.0.0} + echo "LATEST_TAG=$LATEST_TAG" >> "$GITHUB_ENV" + echo "LATEST_TAG=$LATEST_TAG" SEMVER=${LATEST_TAG#v} echo "Current version: $SEMVER" From 63db8fa7332c950d73a1f34be323d3b34f97d521 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 20 Mar 2025 01:10:09 +0200 Subject: [PATCH 10/13] temporarily remove linting and tests --- .github/workflows/develop-workflow.yml | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/develop-workflow.yml b/.github/workflows/develop-workflow.yml index 492db7b8..9ec3a3a9 100644 --- a/.github/workflows/develop-workflow.yml +++ b/.github/workflows/develop-workflow.yml @@ -35,26 +35,26 @@ jobs: ########################################### # LINTING ########################################### - - name: Linting - if: ${{ github.event.pull_request.merged == false }} - uses: ./.github/actions/linting - with: - working_directory: "${{ github.workspace }}/" + # - 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: 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 + # - 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 From 6fecdc2efd54d1eac50d1fb7bcb425e67076c6ab Mon Sep 17 00:00:00 2001 From: Zander Kotze <59666243+ZanderCowboy@users.noreply.github.com> Date: Thu, 20 Mar 2025 13:49:47 +0200 Subject: [PATCH 11/13] update version-bump action --- .github/actions/version-bump/action.yml | 61 +++++++++++++------------ .github/workflows/develop-workflow.yml | 4 +- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/.github/actions/version-bump/action.yml b/.github/actions/version-bump/action.yml index 8caac479..517e5287 100644 --- a/.github/actions/version-bump/action.yml +++ b/.github/actions/version-bump/action.yml @@ -2,17 +2,17 @@ name: "Version Bumper" description: "Bumps semantic version based on PR labels and increments build number." inputs: - github-token: - description: "GitHub token" + github_token: + description: "Github Token" required: true - version-file: + pubspec_file: description: "Path to pubspec file" required: true outputs: - new-version: + new_version: description: "New semantic version generated" - value: ${{ steps.output.outputs.new-version }} + value: ${{ steps.output.outputs.new_version }} runs: using: "composite" @@ -34,18 +34,18 @@ runs: && 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: 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 }} - VERSION_FILE: ${{ inputs.version-file }} + 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') @@ -58,51 +58,56 @@ runs: elif echo "$LABELS" | grep -qi "patch"; then BUMP_TYPE="patch" else - echo "No valid bump label found (major/minor/patch). Exiting." - exit 0 + 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.0.0} + # LATEST_TAG=${LATEST_TAG:-v0.0.0} 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) + PATCH=$(echo "$SEMVER" | cut -d '.' -f 3 | cut -d '+' -f 1) + BUILD=$(echo "$SEMVER" | grep '+' | cut -d '+' -f 2) case $BUMP_TYPE in major) - MAJOR=$((MAJOR + 1)) + MAJOR=$((MAJOR++)) MINOR=0 PATCH=0 ;; minor) - MINOR=$((MINOR + 1)) + MINOR=$((MINOR++)) PATCH=0 ;; patch) - PATCH=$((PATCH + 1)) + PATCH=$((PATCH++)) ;; esac NEW_SEMVER="$MAJOR.$MINOR.$PATCH" + NEW_BUILD=$((BUILD++)) + echo "New version: $NEW_SEMVER" - NEW_VERSION="${NEW_SEMVER}+${{ github.run_number }}" + NEW_VERSION="${NEW_SEMVER}+${NEW_BUILD}" echo "New version with build number: $NEW_VERSION" - sed -i -E "s/^version:.*/version: $NEW_VERSION/" "${{ inputs.version-file }}" + sed -i -E "s/^version:[[:space:]]*.*/version: $NEW_VERSION/" "${{ inputs.pubspec_file }}" - git add "${{ inputs.version-file }}" - git commit -m "chore: bump version to $NEW_VERSION" - git push origin HEAD + # 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}" + # git tag "v${NEW_SEMVER}" + # git push origin "v${NEW_SEMVER}" - echo "new-version=$NEW_VERSION" >> "$GITHUB_OUTPUT" + echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" + echo "new_version=$NEW_VERSION" >> "$GITHUB_ENV" diff --git a/.github/workflows/develop-workflow.yml b/.github/workflows/develop-workflow.yml index 9ec3a3a9..2c3cd5e4 100644 --- a/.github/workflows/develop-workflow.yml +++ b/.github/workflows/develop-workflow.yml @@ -62,8 +62,8 @@ jobs: - name: Bump version based on PR labels uses: ./.github/actions/version-bump with: - github-token: ${{ secrets.GITHUB_TOKEN }} - version-file: "apps/multichoice/pubspec.yaml" + github_token: ${{ secrets.GITHUB_TOKEN }} + pubspec_file: "apps/multichoice/pubspec.yaml" ########################################### # BUILD From 222c0874f9ce4fc5832eec25f3e678bbbbc3ae80 Mon Sep 17 00:00:00 2001 From: Zander Kotze <59666243+ZanderCowboy@users.noreply.github.com> Date: Thu, 20 Mar 2025 13:59:36 +0200 Subject: [PATCH 12/13] fix issue with no build number found --- .github/actions/version-bump/action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/version-bump/action.yml b/.github/actions/version-bump/action.yml index 517e5287..f5df396d 100644 --- a/.github/actions/version-bump/action.yml +++ b/.github/actions/version-bump/action.yml @@ -78,6 +78,10 @@ runs: 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++)) From 24ae935da0f531abac85270059e7554e46fd6302 Mon Sep 17 00:00:00 2001 From: Zander Kotze <59666243+ZanderCowboy@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:11:02 +0200 Subject: [PATCH 13/13] latest tag has no build number, test default --- .github/actions/version-bump/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/version-bump/action.yml b/.github/actions/version-bump/action.yml index f5df396d..b0b416ec 100644 --- a/.github/actions/version-bump/action.yml +++ b/.github/actions/version-bump/action.yml @@ -65,8 +65,8 @@ runs: 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.0.0} + # 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"