Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 83 additions & 76 deletions .github/workflows/beta-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,180 +3,185 @@ name: Beta Release
on:
push:
branches:
- beta
- beta-release

jobs:
release-management:
runs-on: ubuntu-latest
steps:

# Stap 1: Code ophalen
# Step 1: Checkout the repository with full history
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}

# Stap 2: Stel de appnaam in (gebruik de repo-naam)
# Step 2: Set the app name from repository name
- name: Set app env
run: |
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV

# Stap 3: Haal huidige versie uit info.xml, verhoog de patch en voeg beta-suffix toe
# Step 3: Calculate the next beta version
# This reads the main version, increments the patch, and adds/increments the beta suffix
- name: Get current version and append beta suffix
id: increment_version
run: |
# Get version from main branch
# Get the stable version from main branch as base
git fetch origin main
main_version=$(git show origin/main:appinfo/info.xml | grep -oP '(?<=<version>)[^<]+' || echo "")

# Get current version from development branch
# Get current version from beta-release branch
current_version=$(grep -oP '(?<=<version>)[^<]+' appinfo/info.xml || echo "")

# Split main version into parts
# Split main version into parts (e.g., 1.2.5 -> [1, 2, 5])
IFS='.' read -ra main_version_parts <<< "$main_version"

# Increment patch version by 1 from main
# Increment patch version by 1 from main (e.g., 1.2.5 -> 1.2.6)
next_patch=$((main_version_parts[2] + 1))

# Extract beta counter from current version if it exists
# If current version is 1.2.6-beta.1, we'll increment to 1.2.6-beta.2
beta_counter=1
if [[ $current_version =~ -beta\.([0-9]+)$ ]]; then
# If current patch version is still ahead of main, increment counter
# If current patch version matches next patch, increment the counter
current_patch=$(echo $current_version | grep -oP '^[0-9]+\.[0-9]+\.(\d+)' | cut -d. -f3)
if [ "$current_patch" -eq "$next_patch" ]; then
beta_counter=$((BASH_REMATCH[1] + 1))
fi
fi

# Build the new beta version string
beta_version="${main_version_parts[0]}.${main_version_parts[1]}.${next_patch}-beta.${beta_counter}"

# Export version for use in subsequent steps
echo "NEW_VERSION=$beta_version" >> $GITHUB_ENV
echo "new_version=$beta_version" >> $GITHUB_OUTPUT
echo "Main version: $main_version"
echo "Current version: $current_version"
echo "Using beta version: $beta_version"

# Stap 4: Update de versie in info.xml
# Step 4: Update the version in info.xml
- name: Update version in info.xml
run: |
sed -i "s|<version>.*</version>|<version>${{ env.NEW_VERSION }}</version>|" appinfo/info.xml

# Stap 5: Commit de nieuwe versie (indien er wijzigingen zijn)
# Step 5: Commit the new version if there are changes
# The [skip ci] prevents triggering the sync workflow again
- name: Commit version update
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "Bump beta version to ${{ env.NEW_VERSION }} [skip ci]"
git push

# Only commit if there are actual changes
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to commit"
else
git add appinfo/info.xml
git commit -m "Bump beta version to ${{ env.NEW_VERSION }} [skip ci]"
git push
fi

# Stap 6: Bereid de signing certificaten voor
# Step 6: Prepare signing certificates for Nextcloud app signing
- name: Prepare Signing Certificate and Key
run: |
echo "${{ secrets.NEXTCLOUD_SIGNING_CERT }}" > signing-cert.crt
echo "${{ secrets.NEXTCLOUD_SIGNING_KEY }}" > signing-key.key

# Stap 7: Installeer npm dependencies
# Step 7: Install Node.js dependencies
- name: Install npm dependencies
uses: actions/setup-node@v3
with:
node-version: '18.x'

# Stap 8: Stel PHP in en installeer benodigde extensies
# Step 8: Set up PHP with required extensions
- name: Set up PHP and install extensions
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: zip, gd

# Stap 9: Voer npm install, build en composer install uit
# Step 9: Build the app (install dependencies and compile assets)
- run: npm ci
- run: npm run build
- run: composer install --no-dev
# Use production-optimized composer flags for better performance
- run: composer install --no-dev --optimize-autoloader --classmap-authoritative

# Stap 10: Kopieer de bestanden naar de package directory
# Step 10: Copy files to package directory, excluding development files
# This creates a clean distribution package without test files, config files, etc.
- name: Copy the package files into the package
run: |
mkdir -p package/${{ github.event.repository.name }}
rsync -av --progress \
--exclude='package' \
--exclude='.git' \
--exclude='.github' \
--exclude='.vscode' \
--exclude='docker' \
--exclude='docs' \
--exclude='website' \
--exclude='node_modules' \
--exclude='/package' \
--exclude='/.git' \
--exclude='/.github' \
--exclude='/.cursor' \
--exclude='/.vscode' \
--exclude='/node_modules' \
--exclude='/src' \
--exclude='test' \
--exclude='package-lock.json' \
--exclude='composer.lock' \
--exclude='composer-setup.php' \
--exclude='/tests' \
--exclude='/package.json' \
--exclude='/package-lock.json' \
--exclude='/composer.json' \
--exclude='/composer.lock' \
--exclude='/phpcs.xml' \
--exclude='/phpmd.xml' \
--exclude='/psalm.xml' \
--exclude='/phpunit.xml' \
--exclude='/.phpunit.cache' \
--exclude='.phpunit.result.cache' \
--exclude='phpmd.xml' \
--exclude='signing-key.key' \
--exclude='package.json' \
--exclude='composer.json' \
--exclude='coverage.txt' \
--exclude='signing-cert.crt' \
--exclude='docker-compose.yml' \
--exclude='webpack.config.js' \
--exclude='.prettierrc' \
--exclude='psalm.xml' \
--exclude='phpunit.xml' \
--exclude='tsconfig.json' \
--exclude='changelog-ci-config.json' \
--exclude='jest.config.js' \
--exclude='.gitattributes' \
--exclude='.php-cs-fixer.dist.php' \
--exclude='.gitignore' \
--exclude='.eslintrc.js' \
--exclude='stylelint.config.js' \
--exclude='.babelrc' \
--exclude='.nvmrc' \
--exclude='/jest.config.js' \
--exclude='/webpack.config.js' \
--exclude='/tsconfig.json' \
--exclude='/.babelrc' \
--exclude='/.eslintrc.js' \
--exclude='/.prettierrc' \
--exclude='/stylelint.config.js' \
--exclude='/.gitignore' \
--exclude='/.gitattributes' \
--exclude='/signing-key.key' \
--exclude='/signing-cert.crt' \
./ package/${{ github.event.repository.name }}/

# Stap 11: Maak het TAR.GZ archief
# Step 11: Create compressed tarball archive
- name: Create Tarball
run: |
cd package && tar -czf ../nextcloud-release.tar.gz ${{ github.event.repository.name }}

# Stap 12: Sign het TAR.GZ bestand met OpenSSL
# Step 12: Sign the tarball with private key for Nextcloud verification
- name: Sign the TAR.GZ file with OpenSSL
run: |
openssl dgst -sha512 -sign signing-key.key nextcloud-release.tar.gz | openssl base64 -out nextcloud-release.signature

# Stap 13: Genereer Git versie informatie (optioneel, voor logging)
# Step 13: Upload tarball and signature as GitHub artifact for debugging/reference
- name: Upload tarball as artifact
uses: actions/upload-artifact@v4
with:
name: nextcloud-release-${{ env.NEW_VERSION }}
path: |
nextcloud-release.tar.gz
nextcloud-release.signature
retention-days: 30

# Step 14: Generate git version information
- name: Git Version
id: version
uses: codacy/git-version@2.7.1
with:
release-branch: beta

# Stap 14: Extraheer repository description (optioneel)
- name: Extract repository description
id: repo-description
run: |
description=$(jq -r '.description' <(curl -s https://api.github.com/repos/${{ github.repository }}))
echo "REPO_DESCRIPTION=$description" >> $GITHUB_ENV

# Stap 15: Output de versie (voor logging)
- name: Use the version
run: |
echo "Git Version info: ${{ steps.version.outputs.version }}"

rsync -av --progress --exclude='package' --exclude='.git' ./ package/${{ github.event.repository.name }}/
release-branch: beta-release

# Stap 17: Maak een nieuwe GitHub release (als prerelease)
# Step 15: Create GitHub release (marked as prerelease)
- name: Upload Beta Release
uses: ncipollo/release-action@v1.12.0
with:
tag: v${{ env.NEW_VERSION }}
name: Beta Release ${{ env.NEW_VERSION }}
draft: false
prerelease: true
skipIfReleaseExists: true

# Stap 18: Voeg het tarball toe als asset aan de GitHub release
# Step 16: Attach tarball to the GitHub release
- name: Attach tarball to GitHub release
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -186,7 +191,8 @@ jobs:
tag: v${{ env.NEW_VERSION }}
overwrite: true

# Stap 19: Upload de app naar de Nextcloud App Store
# Step 17: Upload the app to Nextcloud App Store
# nightly: false means this is a regular beta release, not a nightly build
- name: Upload app to Nextcloud appstore
uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1
with:
Expand All @@ -196,11 +202,12 @@ jobs:
app_private_key: ${{ secrets.NEXTCLOUD_SIGNING_KEY }}
nightly: false

# Stap 20: Verifieer de release
- name: Verify version and contents
# Step 18: Verify the release contents
# head -50 limits output to first 50 files for readability
- name: Verify release
run: |
echo "App version: ${{ env.NEW_VERSION }}"
echo "Tarball contents:"
tar -tvf nextcloud-release.tar.gz
tar -tvf nextcloud-release.tar.gz | head -50
echo "info.xml contents:"
tar -xOf nextcloud-release.tar.gz ${{ env.APP_NAME }}/appinfo/info.xml
42 changes: 28 additions & 14 deletions .github/workflows/pull-request-from-branch-check.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
name: Main Branch Protection
name: Branch Protection

on:
pull_request:
branches:
- main
pull_request:
branches:
- main
- beta

jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
run: |
if [[ ${GITHUB_HEAD_REF} != development ]] && [[ ${GITHUB_HEAD_REF} != documentation ]] && ! [[ ${GITHUB_HEAD_REF} =~ ^hotfix/ ]];
then
echo "Error: Pull request must come from 'development', 'documentation' or 'hotfix/' branch"
exit 1
fi
check-branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
run: |
TARGET="${{ github.base_ref }}"
SOURCE="${{ github.head_ref }}"

if [[ "$TARGET" == "main" ]]; then
if [[ "$SOURCE" != "beta" ]] && ! [[ "$SOURCE" =~ ^hotfix ]]; then
echo "Error: Pull requests to main must come from 'beta' or a branch starting with 'hotfix'"
echo "Source branch: $SOURCE"
exit 1
fi
elif [[ "$TARGET" == "beta" ]]; then
if [[ "$SOURCE" != "development" ]] && ! [[ "$SOURCE" =~ ^hotfix ]]; then
echo "Error: Pull requests to beta must come from 'development' or a branch starting with 'hotfix'"
echo "Source branch: $SOURCE"
exit 1
fi
fi

echo "Branch check passed: $SOURCE -> $TARGET"
Loading
Loading