Add release.yml

This commit is contained in:
2026-01-30 23:39:54 +01:00
commit dcad7e910a

164
release.yml Normal file
View File

@@ -0,0 +1,164 @@
name: Drop 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:
build-and-release:
name: Build Docker image and create release
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out Drop app source
uses: actions/checkout@v4
with:
repository: Drop-OSS/drop-app
ref: develop
submodules: true
fetch-depth: 3
fetch-tags: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Determine final version
id: get_final_ver
run: |
BASE_VER=v$(jq -r '.version' package.json)
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
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/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 }}
- name: Create Release
uses: softprops/action-gh-release@v1
if: github.event_name != 'schedule'
with:
tag_name: ${{ steps.get_final_ver.outputs.final_ver }}
name: Drop ${{ steps.get_final_ver.outputs.final_ver }}
body: |
## Drop Release ${{ steps.get_final_ver.outputs.final_ver }}
### Docker Images
- `ghcr.io/yindo/drop-builds:${{ steps.get_final_ver.outputs.final_ver }}`
- `ghcr.io/yindo/drop-builds:latest` (for stable releases)
### Changes
Built from [Drop-OSS/drop-app@develop](https://github.com/Drop-OSS/drop-app/tree/develop)
### Docker Usage
```bash
docker pull ghcr.io/yindo/drop-builds:${{ steps.get_final_ver.outputs.final_ver }}
docker run -p 3000:3000 ghcr.io/yindo/drop-builds:${{ steps.get_final_ver.outputs.final_ver }}
```
draft: false
prerelease: ${{ contains(steps.get_final_ver.outputs.final_ver, 'nightly') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Nightly Release
uses: softprops/action-gh-release@v1
if: github.event_name == 'schedule'
with:
tag_name: ${{ steps.get_final_ver.outputs.final_ver }}
name: Drop Nightly ${{ steps.get_final_ver.outputs.final_ver }}
body: |
## Drop Nightly Build ${{ steps.get_final_ver.outputs.final_ver }}
**⚠️ This is a nightly build and may be unstable**
### Docker Images
- `ghcr.io/yindo/drop-builds:${{ steps.get_final_ver.outputs.final_ver }}`
- `ghcr.io/yindo/drop-builds:nightly`
### Changes
Built from [Drop-OSS/drop-app@develop](https://github.com/Drop-OSS/drop-app/tree/develop)
### Docker Usage
```bash
docker pull ghcr.io/yindo/drop-builds:${{ steps.get_final_ver.outputs.final_ver }}
docker run -p 3000:3000 ghcr.io/yindo/drop-builds:${{ steps.get_final_ver.outputs.final_ver }}
```
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}