Skip to content

Commit

Permalink
Merge pull request #9 from federated-wiki/fix/increase-base
Browse files Browse the repository at this point in the history
 introduce base version and versioning helpers
almereyda authored Nov 9, 2023
2 parents 62540b1 + 97efa51 commit 7ce1a1c
Showing 4 changed files with 129 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -3,6 +3,11 @@ name: CI
on:
release:
types: [published]
workflow_call:
inputs:
ref:
required: false
type: string
workflow_dispatch:
inputs:
ref:
63 changes: 63 additions & 0 deletions .github/workflows/increase-base-version.yml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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
60 changes: 60 additions & 0 deletions .github/workflows/release-increased-version.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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/

0 comments on commit 7ce1a1c

Please sign in to comment.