diff --git a/.github/workflows/docker-2x.yml b/.github/workflows/docker-2x.yml deleted file mode 100644 index ca21a59..0000000 --- a/.github/workflows/docker-2x.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Build and push Docker image - -on: - push: - branches: - - 2.x - -jobs: - build-and-push: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push Docker image - run: | - docker buildx build . \ - -f docker/Dockerfile \ - -t vitodeploy/vito:2.x \ - --platform linux/amd64,linux/arm64 \ - --no-cache \ - --push diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index fccf8e3..0fbd2bb 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -2,7 +2,7 @@ name: Build and push Docker image on: release: - types: [created] + types: [ created ] jobs: build-and-push: @@ -28,8 +28,17 @@ jobs: docker buildx build . \ -f docker/Dockerfile \ -t vitodeploy/vito:${{ github.event.release.tag_name }} \ - -t vitodeploy/vito:latest \ --build-arg="RELEASE=0" \ --platform linux/amd64,linux/arm64 \ --no-cache \ --push + + - name: Build and push latest tag + if: startsWith(github.event.release.target_commitish, '1.x') + run: | + docker buildx build . \ + -f docker/Dockerfile \ + -t vitodeploy/vito:latest \ + --build-arg="RELEASE=0" \ + --platform linux/amd64,linux/arm64 \ + --push diff --git a/.github/workflows/docker-1x.yml b/.github/workflows/docker.yml similarity index 89% rename from .github/workflows/docker-1x.yml rename to .github/workflows/docker.yml index 5a9604a..b588fbf 100644 --- a/.github/workflows/docker-1x.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,7 @@ on: push: branches: - 1.x + - 2.x jobs: build-and-push: @@ -28,7 +29,7 @@ jobs: run: | docker buildx build . \ -f docker/Dockerfile \ - -t vitodeploy/vito:1.x \ + -t vitodeploy/vito:${{ github.event.release.target_commitish }} \ --build-arg="RELEASE=0" \ --platform linux/amd64,linux/arm64 \ --no-cache \ diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 0000000..e03712b --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,77 @@ +name: manual release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to release' + required: true + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-24.04 + + name: Release ${{ inputs.version }} + + outputs: + version: ${{ steps.version.outputs.version }} + notes: ${{ steps.cleaned-notes.outputs.notes }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Remove optional "v" prefix + id: version + run: | + echo "version=${VERSION#v}" >> "$GITHUB_OUTPUT" + env: + VERSION: ${{ inputs.version }} + + - name: Check if branch and version match + id: guard + run: | + MAJOR_VERSION="${NUMERIC_VERSION%%.*}" + BRANCH_MAJOR_VERSION="${BRANCH%%.*}" + + if [ "$MAJOR_VERSION" != "$BRANCH_MAJOR_VERSION" ]; then + echo "Mismatched versions! Aborting." + VERSION_MISMATCH='true'; + else + echo "Versions match! Proceeding." + VERSION_MISMATCH='false'; + fi + + echo "VERSION_MISMATCH=$(echo $VERSION_MISMATCH)" >> "$GITHUB_OUTPUT"; + env: + BRANCH: ${{ github.ref_name }} + NUMERIC_VERSION: ${{ steps.version.outputs.version }} + + - name: Fail if branch and release tag do not match + if: ${{ steps.guard.outputs.VERSION_MISMATCH == 'true' }} + uses: actions/github-script@v7 + with: + script: | + core.setFailed('Workflow failed. Release version does not match with selected target branch. Did you select the correct branch?') + + - name: Update config/app.php + run: sed -i "s/'version' => '[^']*'/'version' => '${{ steps.version.outputs.version }}'/" config/app.php + + - name: Commit version change + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Update version to ${{ steps.version.outputs.version }}" + + - name: Create release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.version }} + name: ${{ steps.version.outputs.version }} + body: ${{ steps.cleaned-notes.outputs.notes }} + target_commitish: ${{ github.ref_name }} + make_latest: "${{ github.ref_name == github.event.repository.default_branch }}"