diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 425957b..297333e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,11 @@ name: CI on: release: types: [published] + workflow_call: + inputs: + ref: + required: false + type: string workflow_dispatch: inputs: ref: diff --git a/.github/workflows/increase-base-version.yml b/.github/workflows/increase-base-version.yml new file mode 100644 index 0000000..2442bfa --- /dev/null +++ b/.github/workflows/increase-base-version.yml @@ -0,0 +1,63 @@ +name: Increase base version + +on: + workflow_dispatch: + inputs: + previous-version: + required: true + type: string + next-version: + required: true + type: string + +permissions: + pull-requests: write + packages: write + contents: write + id-token: write + +jobs: + increase-version: + name: Increase version of base image + runs-on: ubuntu-latest + outputs: + pull-request-number: ${{ steps.pr.outputs.pull-request-number }} + steps: + - uses: actions/checkout@v4 + + - name: Upgrade version number + run: | + echo Increase version number from ${{ inputs.previous-version }} to ${{ inputs.next-version }} + sed 's/${{ inputs.previous-version }}/${{ inputs.next-version }}/' -i Dockerfile + - name: Create Pull Request, if needed + id: pr + if: ${{ inputs.previous-version != inputs.next-version }} + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Increase version ${{ inputs.previous-version }} to ${{ inputs.next-version }} + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: false + branch: upgrade/${{ inputs.next-version }} + delete-branch: true + draft: false + title: Increase version ${{ inputs.previous-version }} to ${{ inputs.next-version }} + body: | + A new wiki version ${{ inputs.next-version }} was found. + + Here we are updating from our old version ${{ inputs.previous-version }}. + - name: Merge Pull Request, if needed + if: ${{ steps.pr.outputs.pull-request-number }} != '' + run: | + gh pr merge --merge --auto "$PR" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR: ${{ steps.pr.outputs.pull-request-number }} + + call-release: + name: Call version change detection workflow + needs: ['increase-version'] + if: needs.increase-version.outputs.pull-request-number != '' + uses: ./.github/workflows/release-increased-version.yml + secrets: inherit diff --git a/.github/workflows/release-increased-version.yml b/.github/workflows/release-increased-version.yml new file mode 100644 index 0000000..5018940 --- /dev/null +++ b/.github/workflows/release-increased-version.yml @@ -0,0 +1,60 @@ +name: Detect, tag and release a new version + +on: + push: + branches: + - 'main' + workflow_call: + inputs: + ref: + required: false + type: string + default: ${{ github.ref }} + +permissions: + pull-requests: write + packages: write + contents: write + id-token: write + +jobs: + tag-release: + name: Tag and release a new new version + runs-on: ubuntu-latest + + outputs: + previous-version: ${{ steps.check-version.outputs.previous-version }} + current-version: ${{ steps.check-version.outputs.current-version }} + + steps: + + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + ref: ${{ inputs.ref }} + + - name: Detect and tag new version + uses: salsify/action-detect-and-tag-new-version@v2 + id: check-version + with: + version-command: | + grep WIKI_TAG= Dockerfile | cut -d"=" -f2 + + - name: Release new tag + uses: ncipollo/release-action@v1 + if: steps.check-version.outputs.previous-version != steps.check-version.outputs.current-version + with: + allowUpdates: true + generateReleaseNotes: true + tag: ${{ steps.check-version.outputs.tag }} + updateOnlyUnreleased: true + + call-build-push: + name: Build tagged Container image + needs: ['tag-release'] + uses: ./.github/workflows/ci.yml + if: needs.tag-release.outputs.previous-version != needs.tag-release.outputs.current-version + with: + ref: "refs/tags/v${{ needs.tag-release.outputs.current-version }}" + secrets: inherit diff --git a/Dockerfile b/Dockerfile index 3d65976..c747a0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/federated-wiki/base +FROM ghcr.io/federated-wiki/base:0.32.1 USER root WORKDIR /usr/local/lib/node_modules/wiki/