Skip to content

Check for new version #17600

Check for new version

Check for new version #17600

name: Check for new version
on:
schedule:
- cron: "*/20 * * * *"
push:
branches: ["main"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
actions: write
jobs:
check_new_version:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.check_version.outputs.new_version }}
immich_version: ${{ steps.check_version.outputs.immich_version }}
current_version: ${{ steps.check_version.outputs.current_version }}
steps:
- uses: actions/checkout@v4
- name: Check if new version is available
id: check_version
run: |
current_version=$(curl -sL https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/latest | jq -r '.tag_name')
immich_version=$(curl -sL https://api.github.com/repos/immich-app/immich/releases/latest | jq -r '.tag_name')
if [[ "$current_version" == "null" || "$immich_version" == "null" ]]; then
echo "new_version=false" >> $GITHUB_OUTPUT
fi
if [ "$current_version" != "$immich_version" ]; then
if git tag | grep -q "^$immich_version$"; then
echo "Tag '$immich_version' exists."
else
echo "New immich version ($immich_version) detected."
echo "current_version=$current_version" >> $GITHUB_OUTPUT
echo "immich_version=$immich_version" >> $GITHUB_OUTPUT
echo "new_version=true" >> $GITHUB_OUTPUT
exit 0
fi
else
echo "Immich version ($immich_version) already exists"
fi
echo "new_version=false" >> $GITHUB_OUTPUT
create_new_version:
if: ${{ needs.check_new_version.outputs.new_version == 'true' }}
runs-on: ubuntu-latest
needs: [check_new_version]
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag
run: |
git tag "${{ needs.check_new_version.outputs.immich_version }}"
git push --tags
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ needs.check_new_version.outputs.immich_version }} \
--generate-notes \
--notes "Read Immich release notes [here](https://github.com/immich-app/immich/releases/tag/${{ needs.check_new_version.outputs.immich_version }})"
- name: Get base image tag
id: tag
run: |
mkdir /tmp/immich
curl -o \
/tmp/immich.tar.gz -L \
"https://github.com/immich-app/immich/archive/${{ needs.check_new_version.outputs.immich_version }}.tar.gz" && \
tar xf \
/tmp/immich.tar.gz -C \
/tmp/immich --strip-components=1 && \
dockerfile_content=$(cat /tmp/immich/server/Dockerfile)
date=$(echo "$dockerfile_content" | grep -oP 'base-server-prod:\K\d{8}')
if [ -z "$date" ]; then
base_image_tag="latest";
else
base_image_tag="$date";
fi
echo "base_image_tag=${base_image_tag}" >> $GITHUB_OUTPUT
- name: Trigger workflow
if: github.event_name != 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run docker.yml -f version=${{ needs.check_new_version.outputs.immich_version }} -f base_image_tag=${{ steps.tag.outputs.base_image_tag }}