diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5ea8d97..4c7fdea 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,6 +1,10 @@ name: Docker Image on: workflow_call: + inputs: + version: + required: true + type: string secrets: dockerhub_username: required: true @@ -14,12 +18,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Get version from helm chart - run: | - VERSION=$(grep "version:" ./helm/Chart.yaml | cut -d: -f2 | tr -d ' ') - echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "Version is $VERSION" - - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -37,7 +35,7 @@ jobs: push: true tags: | ${{ secrets.DOCKERHUB_USERNAME }}/scraperr:latest - ${{ secrets.DOCKERHUB_USERNAME }}/scraperr:${{ env.VERSION }} + ${{ secrets.DOCKERHUB_USERNAME }}/scraperr:${{ inputs.version }} - name: Build and push api uses: docker/build-push-action@v5 @@ -47,7 +45,7 @@ jobs: push: true tags: | ${{ secrets.DOCKERHUB_USERNAME }}/scraperr_api:latest - ${{ secrets.DOCKERHUB_USERNAME }}/scraperr_api:${{ env.VERSION }} + ${{ secrets.DOCKERHUB_USERNAME }}/scraperr_api:${{ inputs.version }} push-helm-chart: runs-on: ubuntu-latest diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 224bc0c..cd41331 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -21,4 +21,6 @@ jobs: uses: ./.github/workflows/docker-image.yml secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} \ No newline at end of file + dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} + with: + version: ${{ needs.version.outputs.version }} \ No newline at end of file diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index b140b4e..8e95a9d 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -2,10 +2,18 @@ name: Version on: workflow_call: + outputs: + version: + description: "The new version number" + value: ${{ jobs.version.outputs.version }} jobs: version: runs-on: ubuntu-latest + + outputs: + version: ${{ steps.set_version.outputs.version }} + steps: - name: Checkout uses: actions/checkout@v4 @@ -13,12 +21,10 @@ jobs: fetch-depth: 0 - name: Get version bump - id: version + id: get_version_type run: | - # Get the last commit message COMMIT_MSG=$(git log -1 --pretty=%B) - - # Determine version type based on commit message + if [[ $COMMIT_MSG =~ ^feat\(breaking\) ]]; then VERSION_TYPE="major" elif [[ $COMMIT_MSG =~ ^feat! ]]; then @@ -26,27 +32,29 @@ jobs: elif [[ $COMMIT_MSG =~ ^(feat|fix|chore): ]]; then VERSION_TYPE="patch" else - VERSION_TYPE="patch" # Default to patch for other commit types + VERSION_TYPE="patch" fi - - echo "version_type=$VERSION_TYPE" >> $GITHUB_ENV + + echo "VERSION_TYPE=$VERSION_TYPE" >> $GITHUB_ENV - name: Set version + id: set_version run: | - VERSION=$(./scripts/version.sh ${{ env.VERSION_TYPE }}) + VERSION=$(./scripts/version.sh "$VERSION_TYPE") echo "VERSION=$VERSION" >> $GITHUB_ENV echo "Version is $VERSION" + echo "::set-output name=version::$VERSION" + env: + VERSION_TYPE: ${{ env.VERSION_TYPE }} - name: Update chart file run: | - # Update version in Chart.yaml - sed -i "s/^version: .*/version: ${{ env.VERSION }}/" helm/Chart.yaml - - # Commit and push the changes + sed -i "s/^version: .*/version: $VERSION/" helm/Chart.yaml + git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add helm/Chart.yaml - git commit -m "chore: bump version to ${{ env.VERSION }}" + git commit -m "chore: bump version to $VERSION" git push - - + env: + VERSION: ${{ env.VERSION }} diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 93ea9f4..5c545c8 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: +version: 1.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to