Skip to content

Commit

Permalink
Update workflows to use matrix strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-rds committed Jun 13, 2024
1 parent dfb7993 commit af3c1c7
Show file tree
Hide file tree
Showing 16 changed files with 232 additions and 361 deletions.
33 changes: 7 additions & 26 deletions .github/actions/get-server-version/action.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,29 @@
name: "Get Server Version"
description: "Load latest working stable server version"
description: "Load latest version if input is empty or other pre-determined strings "

inputs:
force:
version:
description: "Version Override"
required: false

outputs:
version:
description: "Clear Version (removes 'v' when necessary"
description: "Version of the Server"
value: ${{ steps.get_version_file.outputs.version }}
is_semver:
description: "If version is a SEMVER or tag/brach"
value: ${{ steps.get_version_file.outputs.is_semver }}
ete_version:
description: "Etebase Version"
value: ${{ steps.get_version_file.outputs.ete_version }}

runs:
using: "composite"
steps:
- id: get_version_file
shell: bash
env:
OVERRIDE: ${{ inputs.force }}
OVERRIDE: ${{ inputs.version }}
run: |
if [ -z "${OVERRIDE}" ]; then
if [ -z "${OVERRIDE}" ] || [ "${OVERRIDE}" = "latest" ] || [ "${OVERRIDE}" = "stable" ] ; then
source ./server_version
else
ETESYNC_VERSION="${OVERRIDE}"
fi
CLEAN_VERSION="${ETESYNC_VERSION#v}"
if [[ ${CLEAN_VERSION} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
SEMVER='true'
else
SEMVER='false'
fi
echo "*Version*: ${CLEAN_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "*Is SemVer*? ${SEMVER}" >> $GITHUB_STEP_SUMMARY
echo "*Etesync Version*: ${ETESYNC_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "version=${CLEAN_VERSION}" >> $GITHUB_OUTPUT
echo "is_semver=${SEMVER}" >> $GITHUB_OUTPUT
echo "ete_version=${ETESYNC_VERSION}" >> $GITHUB_OUTPUT
echo "*Version*: ${ETESYNC_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "version=${ETESYNC_VERSION}" >> $GITHUB_OUTPUT
46 changes: 46 additions & 0 deletions .github/actions/process-version/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Preocess Version Data"
description: "Prepare and extract version information and variants"

inputs:
version:
description: "the target server version"
required: true

outputs:
version:
description: "Clear Version (removes 'v' when necessary)"
value: ${{ steps.get_version_file.outputs.version }}
is_semver:
description: "If version is a SEMVER or tag/brach"
value: ${{ steps.get_version_file.outputs.is_semver }}
ete_version:
description: "Etebase Version"
value: ${{ steps.get_version_file.outputs.ete_version }}

runs:
using: "composite"
steps:
- id: export_version
shell: bash
env:
VERSION: ${{ inputs.version }}
run: |
echo $VERSION
CLEAN_VERSION="${VERSION#v}"
if [[ ${CLEAN_VERSION} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
SEMVER='true'
ETESYNC_VERSION="v${CLEAN_VERSION}"
else
SEMVER='false'
ETESYNC_VERSION="${CLEAN_VERSION}"
fi
echo "*Version*: ${CLEAN_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "*Is SemVer*? ${SEMVER}" >> $GITHUB_STEP_SUMMARY
echo "*Etesync Version*: ${ETESYNC_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "version=${CLEAN_VERSION}" >> $GITHUB_OUTPUT
echo "is_semver=${SEMVER}" >> $GITHUB_OUTPUT
echo "ete_version=${ETESYNC_VERSION}" >> $GITHUB_OUTPUT
30 changes: 14 additions & 16 deletions .github/workflows/call_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:
type: string
version:
description: "EteBase Version"
required: false
required: true
type: string
platforms:
description: "Set the platforms to build [ linux/amd64, linux/arm64 or linux/arm/v7 ]"
default: "linux/amd64,linux/arm64,linux/arm/v7"
description: "Set the platforms to build [ linux/amd64 and/or linux/arm64 ]"
default: "linux/amd64,linux/arm64"
required: false
type: string
tag:
Expand All @@ -39,21 +39,19 @@ jobs:
steps:
- name: Checkout Dockerfiles and Context
uses: actions/checkout@v4
with:
fetch-depth: 0

- id: server_version
name: Get Server Version
uses: ./.github/actions/get-server-version
- id: process_version
name: Process Version data
uses: ./.github/actions/process-version
with:
force: ${{ inputs.version }}
version: ${{ inputs.version }}

- id: build_metadata
name: Prepare Project Metadata
uses: ./.github/actions/build-metadata
with:
flavor: ${{ inputs.flavor }}
version: ${{ steps.server_version.outputs.version }}
version: ${{ steps.process_version.outputs.version }}

- id: docker_metadata
name: Prepare Docker Metadata
Expand All @@ -69,14 +67,14 @@ jobs:
victorrds/etebase
victorrds/etesync
flavor: |
latest=${{ ( inputs.flavor == 'base' && steps.server_version.outputs.is_semver == 'true' ) }}
latest=${{ ( inputs.flavor == 'base' && steps.process_version.outputs.is_semver == 'true' ) }}
suffix=${{ steps.build_metadata.outputs.suffix }}
tags: |
type=edge,enable=${{ inputs.tag != '' }},branch=${{ steps.build_metadata.outputs.source_name }}
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
type=raw,value=${{ inputs.flavor }},suffix=,enable=${{ inputs.tag == '' && steps.server_version.outputs.is_semver == 'true' }}
type=semver,pattern={{version}},value=${{ steps.server_version.outputs.ete_version }},enable=${{ inputs.tag == '' && steps.server_version.outputs.is_semver == 'true' }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.server_version.outputs.ete_version }},enable=${{ inputs.tag == '' && steps.server_version.outputs.is_semver == 'true' }}
type=raw,value=${{ inputs.flavor }},suffix=,enable=${{ inputs.tag == '' && steps.process_version.outputs.is_semver == 'true' }}
type=semver,pattern={{version}},value=${{ steps.process_version.outputs.ete_version }},enable=${{ inputs.tag == '' && steps.process_version.outputs.is_semver == 'true' }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.process_version.outputs.ete_version }},enable=${{ inputs.tag == '' && steps.process_version.outputs.is_semver == 'true' }}
- id: qemu
name: Set up QEMU
Expand All @@ -102,7 +100,7 @@ jobs:
platforms: ${{ inputs.platforms }}
context: .
file: ./tags/${{ inputs.flavor }}/Dockerfile
build-args: ETE_VERSION=${{ steps.server_version.outputs.ete_version }}
build-args: ETE_VERSION=${{ steps.process_version.outputs.ete_version }}
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
push: ${{ inputs.pushit }}
Expand All @@ -118,7 +116,7 @@ jobs:
fi
cat >> summary.md << EOF
Etesync Version: ${{ steps.server_version.outputs.ete_version }}
Etesync Version: ${{ steps.process_version.outputs.ete_version }}
Image Type: ${{ inputs.flavor }}
Platforms: ${{ inputs.platforms }}
EOF
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/call_pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
type: string
version:
description: "EteBase Version"
required: false
required: true
type: string

jobs:
Expand All @@ -21,10 +21,11 @@ jobs:
- name: Checkout Dockerfiles and Context
uses: actions/checkout@v4

- id: server_version
uses: ./.github/actions/get-server-version
- id: process_version
name: Process Version data
uses: ./.github/actions/process-version
with:
force: ${{ inputs.version }}
version: ${{ inputs.version }}

- id: buildx
name: Set up Docker Buildx
Expand All @@ -38,5 +39,5 @@ jobs:
context: .
file: ./tags/${{ inputs.flavor }}/Dockerfile
tags: victorrds/etebase:${{ github.sha }}-${{ inputs.flavor }}
build-args: ETE_VERSION=${{ steps.server_version.outputs.ete_version }}
build-args: ETE_VERSION=${{ steps.process_version.outputs.ete_version }}
push: false
19 changes: 9 additions & 10 deletions .github/workflows/call_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,34 @@ on:
inputs:
version:
description: "EteBase Version"
required: false
required: true
type: string

jobs:
build-n-push:
releases-only:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- id: server_version
uses: ./.github/actions/get-server-version
- id: process_version
name: Process Version data
uses: ./.github/actions/process-version
with:
force: ${{ inputs.version }}
version: ${{ inputs.version }}

- id: create_release
name: Create Release
if: ${{ steps.server_version.outputs.is_semver == 'true' }}
if: ${{ steps.process_version.outputs.is_semver == 'true' }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
removeArtifacts: true
replacesArtifacts: true
commit: ${{ github.sha }}
name: "${{ steps.server_version.outputs.version }}"
name: "${{ steps.process_version.outputs.version }}"
generateReleaseNotes: true
prerelease: false
tag: ${{ steps.server_version.outputs.version }}
tag: ${{ steps.process_version.outputs.version }}
77 changes: 0 additions & 77 deletions .github/workflows/manual-build-all.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/manual-build-single.yml

This file was deleted.

Loading

0 comments on commit af3c1c7

Please sign in to comment.