Files
drop-builds/.gitea/workflows/release.yml
John Doe 220bfa2649
All checks were successful
Release Workflow / Build Docker image (push) Successful in 2m0s
docker fix
2026-01-31 11:41:09 -05:00

197 lines
6.9 KiB
YAML

name: Release Workflow
on:
workflow_dispatch: {}
release:
types: [published]
# This can be used to automatically publish nightlies at UTC nighttime
schedule:
- cron: "0 2 * * *" # run at 2 AM UTC
jobs:
web:
name: Build Docker image
runs-on: ubuntu-latest
services:
docker:
image: docker:dind
options: --privileged
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
repository: Drop-OSS/drop
ref: release-prep
submodules: true
fetch-depth: 3 # fix for when this gets triggered by tag
fetch-tags: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
run: |
echo "Installing Node.js manually for better compatibility..."
# Remove any existing broken Node.js installation
rm -rf /root/.cache/act/tool_cache/node || true
# Install Node.js using package manager
if command -v apt-get >/dev/null 2>&1; then
echo "Using apt-get..."
apt-get update
apt-get install -y nodejs npm
elif command -v apk >/dev/null 2>&1; then
echo "Using apk (Alpine)..."
apk add --no-cache nodejs npm
elif command -v yum >/dev/null 2>&1; then
echo "Using yum..."
yum install -y nodejs npm
else
echo "Downloading Node.js directly..."
cd /tmp
if command -v wget >/dev/null 2>&1; then
wget -q https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.xz
elif command -v curl >/dev/null 2>&1; then
curl -sL https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.xz -o node-v20.11.0-linux-x64.tar.xz
else
echo "Cannot download Node.js - no download tool available"
exit 1
fi
tar -xf node-v20.11.0-linux-x64.tar.xz
export PATH="/tmp/node-v20.11.0-linux-x64/bin:$PATH"
echo "/tmp/node-v20.11.0-linux-x64/bin" >> $GITHUB_PATH
fi
# Verify installation
echo "Node.js version: $(node --version)"
echo "NPM version: $(npm --version)"
echo "Node.js location: $(which node)"
# Verify Node.js installation
- name: Verify Node.js installation
run: |
which node || echo "Node not found in PATH"
node --version || echo "Node version command failed"
npm --version || echo "NPM version command failed"
echo "PATH: $PATH"
- name: Determine final version
id: get_final_ver
run: |
# Ensure Node.js tools are available
if ! command -v node >/dev/null 2>&1; then
echo "Node.js not found, trying alternative version detection..."
if [ -f package.json ]; then
# Try to parse version without jq
BASE_VER="v$(grep '"version"' package.json | sed 's/.*"version": *"\([^"]*\)".*/\1/')"
else
BASE_VER="v0.0.0"
echo "Warning: No package.json found, using default version"
fi
else
# Use jq if available (requires Node.js ecosystem)
if command -v jq >/dev/null 2>&1; then
BASE_VER=v$(jq -r '.version' package.json)
else
# Fallback parsing without jq
BASE_VER="v$(grep '"version"' package.json | sed 's/.*"version": *"\([^"]*\)".*/\1/')"
fi
fi
TODAY=$(date +'%Y.%m.%d')
echo "Today will be: $TODAY"
echo "today=$TODAY" >> $GITHUB_OUTPUT
if [[ "${{ github.event_name }}" == "release" ]]; then
FINAL_VER="$BASE_VER"
else
FINAL_VER="${BASE_VER}-nightly.$TODAY"
fi
echo "Drop's release tag will be: $FINAL_VER"
echo "final_ver=$FINAL_VER" >> $GITHUB_OUTPUT
# Update Docker to compatible version
- name: Update Docker
run: |
echo "Current Docker version:"
docker --version || echo "Docker not found"
# Try to update Docker if possible
if command -v apt-get >/dev/null 2>&1; then
echo "Updating Docker via apt..."
apt-get update
apt-get install -y docker.io || echo "Docker update failed, continuing with existing version"
elif command -v apk >/dev/null 2>&1; then
echo "Updating Docker via apk..."
apk add --no-cache docker || echo "Docker update failed, continuing with existing version"
fi
echo "Updated Docker version:"
docker --version
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: getterup
password: ${{ secrets.RELEASE_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
docker.io/getterup/drop-builds
tags: |
type=schedule,pattern=nightly
type=schedule,pattern=nightly.${{ steps.get_final_ver.outputs.today }}
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=ref,event=branch,prefix=branch-
type=ref,event=pr
type=sha
# set latest tag for stable releases
type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.release.prerelease == false }}
- name: Build and push image
id: build-and-push
run: |
# Ensure Docker client API version is not pinned too low
if [ -n "${DOCKER_API_VERSION}" ]; then
echo "Overriding DOCKER_API_VERSION=${DOCKER_API_VERSION}"
fi
export DOCKER_API_VERSION=1.53
echo "Using DOCKER_API_VERSION=$DOCKER_API_VERSION"
echo "Building image with docker build..."
echo "Tags: ${{ steps.meta.outputs.tags }}"
# Build once with the first tag
FIRST_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
if [ -z "$FIRST_TAG" ]; then
echo "No tags produced by metadata action"
exit 1
fi
docker build \
--build-arg BUILD_DROP_VERSION=${{ steps.get_final_ver.outputs.final_ver }} \
-t "$FIRST_TAG" \
.
# Tag remaining tags
echo "${{ steps.meta.outputs.tags }}" | tail -n +2 | while read -r TAG; do
if [ -n "$TAG" ]; then
docker tag "$FIRST_TAG" "$TAG"
fi
done
# Push all tags
echo "${{ steps.meta.outputs.tags }}" | while read -r TAG; do
if [ -n "$TAG" ]; then
docker push "$TAG"
fi
done