ci: seperated and hopefully improved release cycle

This commit is contained in:
naterfute
2025-09-28 19:35:40 -07:00
parent 9cdd2055b8
commit 63c2158ac0
4 changed files with 117 additions and 106 deletions

View File

@@ -1,93 +0,0 @@
name: Docker Build and Release Workflow
on:
push:
branches:
- main
release:
types:
- published
permissions:
packages: write
contents: write
jobs:
build-dev:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'Update version to')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push canary image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:canary
ghcr.io/${{ github.repository }}:dev
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
create-release-branch:
runs-on: ubuntu-latest
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'bump version')) ||
github.event_name == 'workflow_dispatch'
outputs:
version: ${{ steps.extract-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from commit message or generate
id: extract-version
run: |
VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oE 'v?[0-9]+\.[0-9]+\.[0-9]+')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Using version: $VERSION"
- name: Create release branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b releases/${{ steps.extract-version.outputs.version }}
- name: Update version in config/app.php
run: sed -i "s/'version' => '.*'/'version' => '${{ steps.extract-version.outputs.version }}'/g" config/app.php
- name: Commit version update
run: |
git add config/app.php
git commit -m "Update version to ${{ steps.extract-version.outputs.version }}"
- name: Push release branch
run: git push origin releases/${{ steps.extract-version.outputs.version }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.extract-version.outputs.version }}
target_commitish: releases/${{ steps.extract-version.outputs.version }}
generate_release_notes: true
draft: false
prerelease: false

42
.github/workflows/dev-build.yaml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Docker Build
on:
push:
branches:
- main
permissions:
packages: write
contents: read
jobs:
build-dev:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push canary image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:canary
ghcr.io/${{ github.repository }}:canary-${{ github.sha }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -1,4 +1,4 @@
name: Build and Push Release Docker Image
name: Build and Push release docker image
on:
push:
branches:
@@ -6,6 +6,7 @@ on:
permissions:
packages: write
content: read
jobs:
build-release:
@@ -14,15 +15,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from branch name
id: extract_version
run: |
# Extract version from branch name (e.g., releases/v4.0.0 -> v4.0.0)
BRANCH_NAME=${GITHUB_REF#refs/heads/}
VERSION=${BRANCH_NAME#releases/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
fetch-depth: 1
- name: Login to GHCR
uses: docker/login-action@v3
@@ -45,7 +38,9 @@ jobs:
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
run: |
if ! docker buildx build ...; then
echo "Docker build failed"
exit 1
fi

67
.github/workflows/release.yaml vendored Normal file
View File

@@ -0,0 +1,67 @@
name: Create release
on:
workflow-dispatch:
inputs:
version:
description: 'Version to create (e.g., 1.0.0)'
required: true
type: string
release_type:
description: 'Type of release'
required: true
type: choice
options:
- stable
- prerelease
default: stable
permissions:
contents: write
actions: read
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create release branch
run: |
git config user.name "github-actions[ci]"
git config user.email "ci@pyrodactyl.dev"
git checkout -b releases/v${{ inputs.version }}
- name: Update version in config/app.php
run: sed -i "s/'version' => '.*'/'version' => 'v${{ inputs.version }}'/g" config/app.php
- name: Commit version update
run: |
git add config/app.php
git commit -m "ci: bump v${{ inputs.version }}"
- name: Push release branch
run: git push origin releases/v${{ inputs.version }}
- name: Create release archive
run: |
rm -rf node_modules tests CODE_OF_CONDUCT.md CONTRIBUTING.md flake.lock flake.nix phpunit.xml shell.nix
tar -czf panel.tar.gz * .editorconfig .env.example .eslintignore .eslintrc.js .gitignore .prettierrc.json
- name: Create checksum and add to changelog
run: |
SUM=`sha256sum panel.tar.gz`
echo "$SUM" > checksum.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ inputs.version }}
target_commitish: releases/v${{ inputs.version }}
generate_release_notes: true
draft: false
prerelease: ${{ inputs.release_type == 'prerelease' }}
files: panel.tar.gz