From f39847476cbc24af6daf755dd51be885726cb631 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 25 Aug 2023 18:26:44 +0200 Subject: [PATCH] Change the pre-release versioning scheme and associated environment variables (#26653) --- .github/workflows/build-container-image.yml | 6 ++++-- .github/workflows/build-nightly.yml | 9 ++++----- .github/workflows/build-push-pr.yml | 6 +++--- Dockerfile | 8 ++++---- lib/mastodon/version.rb | 17 ++++++++++++----- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-container-image.yml b/.github/workflows/build-container-image.yml index 1b15d1988..8e9c74766 100644 --- a/.github/workflows/build-container-image.yml +++ b/.github/workflows/build-container-image.yml @@ -8,7 +8,9 @@ on: type: boolean push_to_images: type: string - version_suffix: + version_prerelease: + type: string + version_metadata: type: string flavor: type: string @@ -83,7 +85,7 @@ jobs: - uses: docker/build-push-action@v4 with: context: . - build-args: MASTODON_VERSION_SUFFIX=${{ inputs.version_suffix }} + build-args: MASTODON_VERSION_PRERELEASE=${{ inputs.version_prerelease }} MASTODON_VERSION_METADATA=${{ inputs.version_metadata }} platforms: ${{ inputs.platforms }} provenance: false builder: ${{ steps.buildx.outputs.name || steps.buildx-native.outputs.name }} diff --git a/.github/workflows/build-nightly.yml b/.github/workflows/build-nightly.yml index 5b34c1c3c..5feb2ade3 100644 --- a/.github/workflows/build-nightly.yml +++ b/.github/workflows/build-nightly.yml @@ -16,9 +16,9 @@ jobs: env: TZ: Etc/UTC run: | - echo mastodon_version_suffix=nightly.$(date +'%Y-%m-%d')>> $GITHUB_OUTPUT + echo mastodon_version_prerelease=nightly.$(date +'%Y-%m-%d')>> $GITHUB_OUTPUT outputs: - suffix: ${{ steps.version_vars.outputs.mastodon_version_suffix }} + prerelease: ${{ steps.version_vars.outputs.mastodon_version_prerelease }} build-image: needs: compute-suffix @@ -29,8 +29,7 @@ jobs: push_to_images: | tootsuite/mastodon ghcr.io/mastodon/mastodon - # The `-` is important here, result will be v4.1.2-nightly.2022-03-05 - version_suffix: -${{ needs.compute-suffix.outputs.suffix }} + version_prerelease: ${{ needs.compute-suffix.outputs.prerelease }} labels: | org.opencontainers.image.description=Nightly build image used for testing purposes flavor: | @@ -38,5 +37,5 @@ jobs: tags: | type=raw,value=edge type=raw,value=nightly - type=schedule,pattern=${{ needs.compute-suffix.outputs.suffix }} + type=schedule,pattern=${{ needs.compute-suffix.outputs.prerelease }} secrets: inherit diff --git a/.github/workflows/build-push-pr.yml b/.github/workflows/build-push-pr.yml index 2d2026128..b95e3c14e 100644 --- a/.github/workflows/build-push-pr.yml +++ b/.github/workflows/build-push-pr.yml @@ -21,9 +21,9 @@ jobs: uses: actions/checkout@v3 - id: version_vars run: | - echo mastodon_version_suffix=+pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT + echo mastodon_version_metadata=pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT outputs: - suffix: ${{ steps.version_vars.outputs.mastodon_version_suffix }} + metadata: ${{ steps.version_vars.outputs.mastodon_version_metadata }} build-image: needs: compute-suffix @@ -33,7 +33,7 @@ jobs: use_native_arm64_builder: true push_to_images: | ghcr.io/mastodon/mastodon - version_suffix: ${{ needs.compute-suffix.outputs.suffix }} + version_metadata: ${{ needs.compute-suffix.outputs.metadata }} flavor: | latest=auto tags: | diff --git a/Dockerfile b/Dockerfile index cb5096581..cdabc4c7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,8 +42,8 @@ RUN apt-get update && \ FROM node:${NODE_VERSION} # Use those args to specify your own version flags & suffixes -ARG MASTODON_VERSION_FLAGS="" -ARG MASTODON_VERSION_SUFFIX="" +ARG MASTODON_VERSION_PRERELEASE="" +ARG MASTODON_VERSION_METADATA="" ARG UID="991" ARG GID="991" @@ -89,8 +89,8 @@ ENV RAILS_ENV="production" \ NODE_ENV="production" \ RAILS_SERVE_STATIC_FILES="true" \ BIND="0.0.0.0" \ - MASTODON_VERSION_FLAGS="${MASTODON_VERSION_FLAGS}" \ - MASTODON_VERSION_SUFFIX="${MASTODON_VERSION_SUFFIX}" + MASTODON_VERSION_PRERELEASE="${MASTODON_VERSION_PRERELEASE}" \ + MASTODON_VERSION_METADATA="${MASTODON_VERSION_METADATA}" # Set the run user USER mastodon diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index e3347ca17..c542d5d49 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -16,12 +16,16 @@ module Mastodon 0 end - def flags - ENV['MASTODON_VERSION_FLAGS'].presence || '-beta2' + def default_prerelease + 'beta2' end - def suffix - ENV.fetch('MASTODON_VERSION_SUFFIX', '') + def prerelease + ENV['MASTODON_VERSION_PRERELEASE'].presence || default_prerelease + end + + def build_metadata + ENV.fetch('MASTODON_VERSION_METADATA', nil) end def to_a @@ -29,7 +33,10 @@ module Mastodon end def to_s - [to_a.join('.'), flags, suffix].join + components = [to_a.join('.')] + components << "-#{prerelease}" if prerelease.present? + components << "+#{build_metadata}" if build_metadata.present? + components.join end def repository