Files
pyrodactyl/.github/workflows-disabled/release.yaml
2026-02-11 07:34:57 +00:00

167 lines
6.3 KiB
YAML

name: Release
on:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: blacksmith-2vcpu-ubuntu-2404
permissions:
contents: write
outputs:
release_branch: ${{ steps.get_release_branch.outputs.branch }}
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Enable Corepack
run: |
corepack enable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Auto-increment and push new tag if none exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch all tags
git fetch --tags
# Check if the current push includes a tag
if [ -z "${GITHUB_REF##refs/tags/*}" ]; then
echo "A tag already exists for this push: ${GITHUB_REF}"
exit 0
fi
# Get the latest tag in the vX.X.X format
LATEST_TAG=$(git tag --list "v*" | sort -V | tail -n 1)
# If no tag exists, start with v0.0.1
if [ -z "$LATEST_TAG" ]; then
NEW_TAG="v0.0.1"
else
# Extract the major, minor, and patch numbers
MAJOR=$(echo $LATEST_TAG | cut -d. -f1 | tr -d 'v')
MINOR=$(echo $LATEST_TAG | cut -d. -f2)
PATCH=$(echo $LATEST_TAG | cut -d. -f3)
# Increment the patch version
PATCH=$((PATCH + 1))
# Create the new tag
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"
fi
# Push the new tag
git tag $NEW_TAG
git push origin $NEW_TAG
- name: Get the latest tag
id: get_latest_tag
run: |
# Fetch all tags
git fetch --tags
# Get the latest tag in the vX.X.X format
LATEST_TAG=$(git tag --list "v*" | sort -V | tail -n 1)
# Set the output variable
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Create release branch and bump version
id: get_release_branch
run: |
BRANCH=release/${{ steps.get_latest_tag.outputs.latest_tag }}
git config --local user.email "naterfute@pyro.host"
git config --local user.name "Pyrodactyl CI"
git checkout -b $BRANCH
git push -u origin $BRANCH
sed -i "s/'version' => '[0-9]\+\.[0-9]\+\.[0-9]\+',/'version' => '${{ steps.get_latest_tag.outputs.latest_tag }}:1',/" config/app.php
git add config/app.php
git commit -m "ci(release): bump version"
git push
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
- name: Create release archive
run: |
rm -rf node_modules tests CODE_OF_CONDUCT.md CONTRIBUTING.md flake.lock flake.nix phpunit.xml shell.nix
chmod -R 755 storage/* bootstrap/cache/
tar -czf panel.tar.gz * .editorconfig .env.example .gitignore .prettierrc.json
- name: Extract changelog
run: |
echo "This changelog was automatically pulled. It is not guaranteed to be accurate." # Thanks, GitHub Copilot, that's great wording!
sed -n "/^## ${{ steps.get_latest_tag.outputs.latest_tag }}/,/^## /{/^## /b;p}" CHANGELOG.md > ./RELEASE_CHANGELOG
- name: Create checksum and add to changelog
run: |
SUM=`sha256sum panel.tar.gz`
echo -e "\n#### SHA256 Checksum\n\n\`\`\`\n$SUM\n\`\`\`\n" >> ./RELEASE_CHANGELOG
echo $SUM > checksum.txt
- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Alpha ${{ steps.get_latest_tag.outputs.latest_tag }}
tag_name: ${{ steps.get_latest_tag.outputs.latest_tag }}
draft: true
prerelease: ${{ contains(github.ref, 'rc') || contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
body_path: ./RELEASE_CHANGELOG
- name: Upload release archive
id: upload-release-archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./panel.tar.gz
asset_name: panel.tar.gz
asset_content_type: application/gzip
- name: Upload release checksum
id: upload-release-checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./checksum.txt
asset_name: checksum.txt
asset_content_type: text/plain
- name: Upload release changelog
id: upload-release-changelog
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./RELEASE_CHANGELOG
asset_name: RELEASE_CHANGELOG
asset_content_type: text/markdown
- name: Publish release
id: publish_release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}