Compare and increase version #335
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Compare and increase version | |
on: | |
schedule: | |
- cron: '37 04 * * *' | |
workflow_dispatch: | |
permissions: | |
pull-requests: write | |
packages: write | |
contents: write | |
id-token: write | |
jobs: | |
compare-increase-version: | |
name: Compare and conditionally increase release version | |
runs-on: ubuntu-latest | |
outputs: | |
pull-request-number: ${{ steps.pr.outputs.pull-request-number }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Pull and register current version in Dockerfile | |
id: dockerfile | |
run: | | |
dockerfile_version=`grep -P '(?<=WIKI_TAG=).*' -o Dockerfile` | |
echo $dockerfile_version | |
echo "version=$dockerfile_version" >> $GITHUB_OUTPUT | |
- name: Pull and register current version in Compose environment | |
id: environment | |
run: | | |
environment_version=`grep -P '(?<=IMAGE_TAG=).*' -o .env` | |
echo $environment_version | |
echo "version=$environment_version" >> $GITHUB_OUTPUT | |
- name: Pull and register current version at NPM | |
if: ${{ steps.dockerfile.outputs.version == steps.environment.outputs.version }} | |
id: npm | |
run: | | |
npm_version=`curl -sL https://registry.npmjs.org/wiki/latest | jq -r .version` | |
echo $npm_version | |
echo "version=$npm_version" >> $GITHUB_OUTPUT | |
- name: Modify version numbers, if needed | |
if: ${{ steps.dockerfile.outputs.version != steps.npm.outputs.version }} | |
run: | | |
echo Version ${{ steps.dockerfile.outputs.version }} in Dockerfile is not equal to the NPM version ${{ steps.npm.outputs.version }}. | |
sed 's/${{ steps.dockerfile.outputs.version }}/${{ steps.npm.outputs.version }}/' -i Dockerfile .env | |
- name: Create Pull Request, if needed | |
id: pr | |
if: ${{ steps.dockerfile.outputs.version != steps.npm.outputs.version }} | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: Increase version ${{ steps.dockerfile.outputs.version }} to ${{ steps.npm.outputs.version }} | |
committer: GitHub <[email protected]> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
signoff: false | |
branch: upgrade/${{ steps.npm.outputs.version }} | |
delete-branch: true | |
draft: false | |
title: Increase version ${{ steps.dockerfile.outputs.version }} to ${{ steps.npm.outputs.version }} | |
body: | | |
The new wiki version ${{ steps.npm.outputs.version }} was found on NPM. | |
Here we are updating from our old version ${{ steps.dockerfile.outputs.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: ['compare-increase-version'] | |
if: needs.compare-increase-version.outputs.pull-request-number != '' | |
uses: ./.github/workflows/release-increased-version.yml | |
with: | |
ref: main | |
secrets: inherit |