Skip to content

Release image

Release image #68

Workflow file for this run

---
name: Release image
on: # yamllint disable-line rule:truthy
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
check_versions:
name: Release - Version checking
runs-on: ubuntu-latest
outputs:
base_version: ${{ steps.sogo.outputs.VERSION }}
revision: ${{ steps.image.outputs.REVISION }}
next_revision: ${{ steps.image.outputs.NEXT_REVISION }}
release: ${{ steps.condition.outputs.RELEASE }}
steps:
- name: Get latest version of SOGo
id: sogo
run: |
echo "VERSION=$(curl -s https://github.com/gitapi/repos/Alinto/sogo/releases/latest | jq -r '.tag_name' | sed 's/SOGo-//')" >> "$GITHUB_OUTPUT"
- name: Get latest version of Docker image
id: image
run: |
RAW_LATEST_RELEASE=$(curl -s https://github.com/gitapi/repos/${GITHUB_REPOSITORY}/releases/latest)
VERSION=$(echo "$RAW_LATEST_RELEASE" | jq -r '.tag_name')
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "BASE_VERSION=$(echo "$VERSION" | sed 's/-.*//')" >> "$GITHUB_OUTPUT"
REVISION=$([[ "$VERSION" == *-* ]] && echo "$VERSION" | sed 's/.*-//' || echo "")
echo "REVISION=$REVISION" >> "$GITHUB_OUTPUT"
NEXT_REVISION=$([[ "$REVISION" =~ ^[0-9]+$ ]] && echo $(($REVISION + 1)) || echo 1)
echo "NEXT_REVISION=$NEXT_REVISION" >> "$GITHUB_OUTPUT"
- name: Decide if release version or not
id: condition
env:
SOGO_VERSION: ${{steps.sogo.outputs.VERSION}}
DOCKER_VERSION: ${{steps.image.outputs.BASE_VERSION}}
DOCKER_REVISION: ${{steps.image.outputs.REVISION}}
ACTION_TRIGGER: ${{github.event_name}}
run: |
VERSIONS_ARE_EQUAL=$([ "$SOGO_VERSION" = "$DOCKER_VERSION" ] && echo "true" || echo "false")
if [ "$ACTION_TRIGGER" = "workflow_dispatch" ] || [ "$VERSIONS_ARE_EQUAL" != "true" ]; then
RELEASE="true"
else
RELEASE="false"
fi
echo "RELEASE=$RELEASE" >> "$GITHUB_OUTPUT"
release:
name: Release - Docker image
needs: check_versions
runs-on: ubuntu-latest
if: needs.check_versions.outputs.release == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker - Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Docker - GHCR Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker - Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ needs.check_versions.outputs.base_version }}
type=raw,value=${{ needs.check_versions.outputs.base_version }}-${{ needs.check_versions.outputs.next_revision }}
flavor: latest=true
- name: Docker - Build / Push
id: docker_build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
SOGO_VERSION=${{ needs.check_versions.outputs.base_version }}
- name: Github Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.check_versions.outputs.base_version }}-${{ needs.check_versions.outputs.next_revision }}
make_latest: 'true'
generate_release_notes: true
body: |
SOGo Update: https://github.com/Alinto/sogo/releases/tag/SOGo-${{ needs.check_versions.outputs.base_version }}
- name: Update Chart AppVersion
env:
APP_VERSION: ${{needs.check_versions.outputs.base_version}}
DOCKER_REVISION: ${{needs.check_versions.outputs.next_revision}}
run: |
CHART_PATH="charts/sogo/Chart.yaml"
sed -i 's|sonroyaalmerol/docker-sogo:[^ ]*|sonroyaalmerol/docker-sogo:'"$APP_VERSION"'-'"$DOCKER_REVISION"'|g' "$CHART_PATH"
sed -i 's/^appVersion:.*$/appVersion: '"$APP_VERSION"'/' "$CHART_PATH"
- name: Commit files and push it
run: |
git add .
git commit -m "chore: bump container versions in chart"
git push
release_helm:
needs: release
uses: sonroyaalmerol/docker-sogo/.github/workflows/helm-release.yml@main