Files
drop-builds/.gitea/workflows/release.yml
2026-01-31 11:29:44 -05:00

207 lines
7.3 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: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
driver: docker
continue-on-error: true
# Fallback Buildx setup if the main one fails
- name: Fallback Docker Buildx setup
if: failure()
run: |
echo "Setting up Docker Buildx manually as fallback..."
docker buildx create --use --name fallback-builder --driver docker-container || true
docker buildx inspect --bootstrap || echo "Buildx bootstrap failed, continuing..."
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: free-git.org
username: ${{ secrets.REGISTRY_USERNAME || github.actor }}
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITEA_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
free-git.org/yindo/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: Cache
uses: actions/cache@v4
id: cache
with:
path: cache-mount
key: cache-mount-${{ hashFiles('Dockerfile') }}
- name: Restore Docker cache mounts
uses: reproducible-containers/buildkit-cache-dance@v3
with:
builder: ${{ steps.buildx.outputs.name }}
cache-dir: cache-mount
dockerfile: Dockerfile
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Build and push image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: true
provenance: mode=max
sbom: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DROP_VERSION=${{ steps.get_final_ver.outputs.final_ver }}