diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2422087..b88ee35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,8 +20,33 @@ jobs: uses: actions/checkout@v4 with: submodules: true + fetch-tags: true token: ${{ secrets.GITHUB_TOKEN }} + - name: Get base tag + id: get_base_tag + run: | + BASE_TAG=$(git describe --tags --abbrev=0) + echo "base_tag=$BASE_TAG" >> $GITHUB_OUTPUT + + - name: Determine final tag + id: get_final_tag + run: | + BASE_TAG=${{ steps.get_base_tag.outputs.base_tag }} + TODAY=$(date +'%Y.%m.%d') + + echo "Today will be: $TODAY" + echo "today=$TODAY" >> $GITHUB_OUTPUT + + if [[ "${{ github.event_name }}" == "release" ]]; then + FINAL_TAG="$BASE_TAG" + else + FINAL_TAG="${BASE_TAG}-nightly.$TODAY" + fi + + echo "Drop's release tag will be: $FINAL_TAG" + echo "final_tag=$FINAL_TAG" >> $GITHUB_OUTPUT + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -45,7 +70,7 @@ jobs: images: | ghcr.io/drop-OSS/drop tags: | - type=schedule,pattern=nightly + type=schedule,pattern=nightly.${{ steps.get_final_tag.outputs.today }} type=semver,pattern=v{{version}} type=semver,pattern=v{{major}}.{{minor}} type=semver,pattern=v{{major}} @@ -66,3 +91,5 @@ jobs: platforms: linux/amd64,linux/arm64 cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + BUILD_DROP_VERSION=${{ steps.get_final_tag.outputs.final_tag }} diff --git a/Dockerfile b/Dockerfile index 73ba58f..ac6caa5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + # Unified deps builder FROM node:lts-alpine AS deps WORKDIR /app @@ -12,10 +14,15 @@ WORKDIR /app ENV NODE_ENV=production ENV NUXT_TELEMETRY_DISABLED=1 +# add git so drop can determine its git ref at build +RUN apk add git + # copy deps and rest of project files COPY --from=deps /app/node_modules ./node_modules COPY . . +ARG BUILD_DROP_VERSION="v0.0.0-unknown.1" + # build RUN yarn postinstall RUN yarn build diff --git a/server/tasks/check/update.ts b/server/tasks/check/update.ts index 4823f74..5a35e51 100644 --- a/server/tasks/check/update.ts +++ b/server/tasks/check/update.ts @@ -92,6 +92,7 @@ export default defineTask({ }; } + // TODO: handle prerelease identifiers https://github.com/npm/node-semver#prerelease-identifiers // check if is newer version if (semver.gt(latestVer, currVer)) { console.log("[Task check:update]: Update available");