diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec93674..2394faf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,8 @@ on: jobs: release: + # Only run on the original repository, not forks + if: ${{ github.repository_owner == 'varun-raj' }} runs-on: ubuntu-latest permissions: contents: write @@ -32,19 +34,34 @@ jobs: contents: read packages: write needs: release - if: needs.release.outputs.new-release-published == 'true' + if: always() && !failure() steps: - uses: actions/checkout@v3 + - uses: docker/metadata-action@v5 + name: Docker meta + id: meta + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest,enable=${{ github.repository_owner != 'varun-raj' || needs.release.outputs.new-release-published == 'true' }} + type=semver,pattern={{major}}.{{minor}}.{{patch}},enable=${{ github.repository_owner == 'varun-raj' && needs.release.outputs.new-release-published == 'true' }} - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image - run: | - echo VERSION=${{ needs.release.outputs.new-release-version }} >> .env - docker build -t ghcr.io/${{ github.repository }}:${{ needs.release.outputs.new-release-version }} \ - -t ghcr.io/${{ github.repository }}:latest . - docker push ghcr.io/${{ github.repository }}:latest - docker push ghcr.io/${{ github.repository }}:${{ needs.release.outputs.new-release-version }} + - name: Build and push + id: docker-build + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + VERSION=${{ needs.release.outputs.new-release-version || 'dev' }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 629fe2f..a295930 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,11 @@ RUN npm run build # Production image, copy all the files and run next FROM node:18-alpine AS runner WORKDIR /app +# Define a build argument +ARG VERSION=dev + +# Set the build argument as an environment variable +ENV VERSION=$VERSION ENV NODE_ENV=production diff --git a/package.json b/package.json index abe8db2..e299d7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immich-power-tools", - "version": "0.8.0", + "version": "0.9.0", "private": true, "scripts": { "dev": "next dev",