A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
feat: workflows for 3 types of branches
aminnausin0917dbe36388
diff --git a/.github/workflows/ci-docker-release.yml b/.github/workflows/ci-docker-release.ymlindex 0c5b557b..88922f1f 100644--- a/.github/workflows/ci-docker-release.yml+++ b/.github/workflows/ci-docker-release.yml@@ -22,6 +22,7 @@ jobs:strategy:fail-fast: trueuses: ./.github/workflows/tests.yml+# ==========================# Generate Release Tags# ==========================@@ -64,11 +65,7 @@ jobs:if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then- #Only increase patch version if merging feature branch to main (previously dev)- IS_MERGE=$(git log -1 --pretty=%P | wc -w)- if [ "$IS_MERGE" -gt 1 ]; then- PATCH=$((PATCH + 1))- fi+ # any commit or merge to main updates the beta counter - this version holds the future base versionNEW_VERSION="$MAJOR.$MINOR.$PATCH"@@ -130,6 +127,7 @@ jobs:git tag ${{ steps.set_release_info.outputs.TAG }}git push origin ${{ steps.set_release_info.outputs.TAG }}+# ==========================# Publish Docker Image# ==========================@@ -165,6 +163,7 @@ jobs:tags: |aminnausin/mediaserver:${{ needs.get-release-tags.outputs.docker-tag }}aminnausin/mediaserver:${{ needs.get-release-tags.outputs.tag }}+# ==========================# Check for Docker Changes# ==========================diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.ymlnew file mode 100644index 00000000..4c2ed900--- /dev/null+++ b/.github/workflows/ci-main.yml@@ -0,0 +1,228 @@+name: CI & Docker Release (Beta)++concurrency:+ group: beta-main+ cancel-in-progress: false++on:+ push:+ branches: [ 'main' ]+ paths-ignore:+ - "VERSION"+ workflow_dispatch:+ inputs:+ bump:+ description: 'Version bump type'+ required: true+ default: 'minor'+ type: choice+ options:+ - major+ - minor++jobs:+ run-tests:+ permissions:+ contents: write+ strategy:+ fail-fast: true+ uses: ./.github/workflows/tests.yml++ # ==========================+ # Generate Beta Tags+ # ==========================+ get-beta-tags:+ name: Generate Beta Tags+ runs-on: ubuntu-latest+ needs: run-tests+ permissions:+ contents: write+ strategy:+ fail-fast: true+ outputs:+ tag: ${{ steps.beta.outputs.TAG }}++ steps:+ - name: Checkout Repository+ uses: actions/checkout@v4++ - name: Ensure VERSION file exists+ run: |+ VERSION_FILE="VERSION"+ if [ ! -f "$VERSION_FILE" ]; then+ echo "0.1.0" > "$VERSION_FILE"+ fi++ - name: Fetch full git history and tags+ run: |+ git fetch --unshallow --tags || git fetch --tags++ - name: Calculate beta version+ id: beta+ run: |+ VERSION_FILE="VERSION"+ CURRENT_VERSION=$(cat $VERSION_FILE)+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"++ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then+ INCREMENT="${{ github.event.inputs.bump }}"+ INCREMENT="${INCREMENT:-minor}"++ case $INCREMENT in+ major)+ MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;+ minor|*)+ MINOR=$((MINOR + 1)); PATCH=0 ;;+ esac+ fi++ if [ "$PATCH" != "0" ]; then+ echo "ERROR: main branch cannot hold patch versions (found $CURRENT_VERSION)"+ echo "::error::Main branch should only have X.Y.0 versions"+ exit 1+ fi++ # any commit or merge to main updates the beta counter - this version holds the future base version++ NEW_VERSION="$MAJOR.$MINOR.$PATCH"++ LAST_BETA=$(git tag --list "${NEW_VERSION}-beta.[0-9]*" | sed -E "s/.*-beta\.//" | sort -V | tail -n1)+ LAST_BETA=${LAST_BETA:-0}+ BUILD_COUNT=$((LAST_BETA + 1))++ TAG="${NEW_VERSION}-beta.${BUILD_COUNT}"++ echo "::notice::Beta Tag: $TAG"++ echo "$NEW_VERSION" > $VERSION_FILE+ echo "TAG=$TAG" >> $GITHUB_OUTPUT++ - name: Commit updated VERSION file and manifest+ uses: stefanzweifel/git-auto-commit-action@v5+ with:+ commit_message: 'chore: bump version to ${{ steps.beta.outputs.TAG }}'+ file_pattern: |+ VERSION++ - name: Create and push Git tag+ if: steps.beta.outputs.TAG != ''+ env:+ TAG: ${{ steps.beta.outputs.TAG }}+ run: |+ git config user.name "github-actions[bot]"+ git config user.email "github-actions[bot]@users.noreply.github.com"++ if git rev-parse "$TAG" >/dev/null 2>&1; then+ echo "Tag already exists."+ exit 0+ fi++ git tag "$TAG"+ git push origin "$TAG"++ # ==========================+ # Publish Docker Image+ # ==========================+ build-docker:+ name: Build Docker Image+ runs-on: ubuntu-latest+ needs: [ get-beta-tags ]+ permissions:+ contents: write++ steps:+ - name: Checkout Repository+ uses: actions/checkout@v4+ with:+ fetch-depth: 0+ submodules: false # Optional — only needed if using submodules+ persist-credentials: false # not needed unless you push++ - name: Update .env.docker+ run: |+ sed -i "s/DOCKER_RELEASE=.*/DOCKER_RELEASE=beta/" docker/.env.docker++ - name: Login to Docker Hub+ uses: docker/login-action@v3+ with:+ username: ${{ secrets.DOCKER_HUB_USERNAME }}+ password: ${{ secrets.DOCKER_HUB_TOKEN }}++ - name: Push to Docker Hub+ uses: docker/build-push-action@v6+ with:+ context: .+ push: true+ tags: |+ aminnausin/mediaserver:beta+ aminnausin/mediaserver:${{ needs.get-beta-tags.outputs.tag }}++ # ==========================+ # Check for Docker Changes+ # ==========================+ check-docker-changes:+ name: Check for Docker Related File Changes+ needs: [ run-tests ]+ if: needs.run-tests.result == 'success'+ runs-on: ubuntu-latest+ outputs:+ files_changed: ${{ steps.filter.outputs.changes != '[]' }}++ steps:+ - name: Checkout code+ uses: actions/checkout@v4++ - name: Check for file changes+ id: filter+ uses: dorny/paths-filter@v2+ with:+ filters: |+ changed:+ - 'docker/**'+ - 'docker-compose.yaml'+ - 'Dockerfile'+ - 'startDocker.*'+ - 'data/**'+ - 'README.md'++ # ==========================+ # Release Docker Setup Pkg+ # ==========================+ release:+ name: Create GitHub Release+ runs-on: ubuntu-latest+ needs: [ build-docker, check-docker-changes, get-beta-tags ]+ if: needs.check-docker-changes.outputs.files_changed == 'true' || github.event_name == 'workflow_dispatch'+ permissions:+ contents: write++ steps:+ - name: Checkout Repository+ uses: actions/checkout@v4++ - name: Prepare default data files for release+ run: |+ mkdir -p data+ cp -r storage/app/public/* data++ - name: Zip Files Linux+ run: |+ zip -r mediaServerDockerLinux.zip ./docker/etc ./docker/.env.docker ./docker-compose.yaml ./startDocker.sh ./README.md ./data/*++ - name: Zip Files Windows+ run: |+ zip -r mediaServerDockerWindows.zip ./docker/etc ./docker/.env.docker ./docker-compose.yaml ./startDocker.bat ./README.md ./data/* ./add-hosts-entry.ps1++ - name: Cleanup temp+ run: rm -rf temp++ - name: Create Release+ uses: ncipollo/release-action@v1+ with:+ allowUpdates: false+ token: ${{ secrets.GITHUB_TOKEN }}+ tag: ${{ needs.get-beta-tags.outputs.tag }}+ name: Docker Release - ${{ needs.get-beta-tags.outputs.tag }}+ draft: false+ prerelease: true+ artifacts: mediaServerDockerLinux.zip,mediaServerDockerWindows.zipdiff --git a/.github/workflows/ci-prod.yml b/.github/workflows/ci-prod.ymlnew file mode 100644index 00000000..a04ec11b--- /dev/null+++ b/.github/workflows/ci-prod.yml@@ -0,0 +1,230 @@+name: CI & Docker Release++on:+ pull_request:+ branches:+ - 'prod'+ types:+ - closed++jobs:+ run-tests:+ if: github.event.pull_request.merged == true+ permissions:+ contents: write+ strategy:+ fail-fast: true+ uses: ./.github/workflows/tests.yml++ # ==========================+ # Handle Prod Release Tags+ # ==========================+ release-flow:+ name: Handle Releases Tags+ runs-on: ubuntu-latest+ needs: run-tests+ permissions:+ contents: write+ strategy:+ fail-fast: true+ outputs:+ tag: ${{ steps.version.outputs.TAG }}++ steps:+ - name: Checkout Repository+ uses: actions/checkout@v4+ with:+ ref: prod++ - name: Ensure VERSION file exists+ run: |+ VERSION_FILE="VERSION"+ if [ ! -f "$VERSION_FILE" ]; then+ echo "0.1.0" > "$VERSION_FILE"+ fi++ - name: Fetch full git history and tags+ run: |+ git fetch --unshallow --tags || git fetch --tags++ - name: Bump version+ id: version+ run: |+ VERSION_FILE="VERSION"+ CURRENT_VERSION=$(cat $VERSION_FILE)+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"++ # Prod never updates any versions on its own+ TAG="$MAJOR.$MINOR.$PATCH"++ echo "::notice::Release Tag: $TAG"+ echo "TAG=$TAG" >> $GITHUB_OUTPUT++ - name: Create and push Git tag+ if: steps.version.outputs.TAG != ''+ env:+ TAG: ${{ steps.version.outputs.TAG }}+ run: |+ git config user.name "github-actions[bot]"+ git config user.email "github-actions[bot]@users.noreply.github.com"++ if git rev-parse "$TAG" >/dev/null 2>&1; then+ echo "Tag already exists."+ exit 0+ fi++ git tag ${{ steps.version.outputs.TAG }}+ git push origin ${{ steps.version.outputs.TAG }}++ # ==========================+ # Publish Docker Image+ # ==========================+ build-docker:+ name: Build Docker Image+ runs-on: ubuntu-latest+ needs: [ release-flow ]+ permissions:+ contents: write++ steps:+ - name: Checkout Repository+ uses: actions/checkout@v4+ with:+ ref: prod+ fetch-depth: 0+ submodules: false # Optional — only needed if using submodules+ persist-credentials: false # not needed unless you push++ - name: Update .env.docker+ run: |+ sed -i "s/DOCKER_RELEASE=.*/DOCKER_RELEASE=latest/" docker/.env.docker++ - name: Login to Docker Hub+ uses: docker/login-action@v3+ with:+ username: ${{ secrets.DOCKER_HUB_USERNAME }}+ password: ${{ secrets.DOCKER_HUB_TOKEN }}++ - name: Push to Docker Hub+ uses: docker/build-push-action@v6+ with:+ context: .+ push: true+ tags: |+ aminnausin/mediaserver:latest+ aminnausin/mediaserver:${{ needs.release-flow.outputs.tag }}++ # ==========================+ # Check for Docker Changes+ # ==========================+ check-docker-changes:+ name: Check for Docker Related File Changes+ needs: [ run-tests ]+ if: needs.run-tests.result == 'success'+ runs-on: ubuntu-latest+ outputs:+ files_changed: ${{ steps.filter.outputs.changes != '[]' }}++ steps:+ - name: Checkout code+ uses: actions/checkout@v4+ with:+ ref: prod++ - name: Check for file changes+ id: filter+ uses: dorny/paths-filter@v2+ with:+ filters: |+ changed:+ - 'docker/**'+ - 'docker-compose.yaml'+ - 'Dockerfile'+ - 'startDocker.*'+ - 'data/**'+ - 'README.md'++ # ==========================+ # Release Docker Setup Pkg (Always)+ # ==========================+ release:+ name: Create GitHub Release+ runs-on: ubuntu-latest+ needs: [ build-docker, check-docker-changes, release-flow ]+ permissions:+ contents: write++ steps:+ - name: Checkout Repository+ uses: actions/checkout@v4+ with:+ ref: prod++ - name: Prepare default data files for release+ run: |+ mkdir -p data+ cp -r storage/app/public/* data++ - name: Zip Files Linux+ run: |+ zip -r mediaServerDockerLinux.zip ./docker/etc ./docker/.env.docker ./docker-compose.yaml ./startDocker.sh ./README.md ./data/*++ - name: Zip Files Windows+ run: |+ zip -r mediaServerDockerWindows.zip ./docker/etc ./docker/.env.docker ./docker-compose.yaml ./startDocker.bat ./README.md ./data/* ./add-hosts-entry.ps1++ - name: Cleanup temp+ run: rm -rf temp++ - name: Create Release+ uses: ncipollo/release-action@v1+ with:+ allowUpdates: false+ token: ${{ secrets.GITHUB_TOKEN }}+ tag: ${{ needs.release-flow.outputs.tag }}+ name: Release - ${{ needs.release-flow.outputs.tag }}+ draft: false+ prerelease: false+ artifacts: mediaServerDockerLinux.zip,mediaServerDockerWindows.zip++ # ==========================+ # Bump Main to Next Version (Only on Prod)+ # ==========================+ bump-main-version:+ name: Bump Main to Next Beta Base Version+ needs: release-flow+ if: needs.release-flow.outputs.tag != '' && github.event.pull_request.head.ref == 'main' && github.event.pull_request.merged == true+ runs-on: ubuntu-latest+ permissions:+ contents: write++ steps:+ - uses: actions/checkout@v4+ with:+ ref: main++ - name: Bump main version+ run: |+ VERSION_FILE="VERSION"+ CURRENT_VERSION=$(cat $VERSION_FILE)++ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"++ # Always bump MINOR after prod+ MINOR=$((MINOR + 1))+ PATCH=0++ NEW_VERSION="$MAJOR.$MINOR.$PATCH"+ TAG="${NEW_VERSION}-beta.0"++ echo "$NEW_VERSION" > $VERSION_FILE++ git config user.name "github-actions[bot]"+ git config user.email "github-actions[bot]@users.noreply.github.com"++ git add VERSION+ git commit -m "chore: bump main to $TAG"+ git push origin main++ git tag $TAG+ git push origin $TAGdiff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.ymlnew file mode 100644index 00000000..66d955fe--- /dev/null+++ b/.github/workflows/ci-release.yml@@ -0,0 +1,85 @@+name: CI Patch RC++on:+ push:+ branches:+ - 'release/*'++jobs:+ run-tests:+ permissions:+ contents: write+ strategy:+ fail-fast: true+ uses: ./.github/workflows/tests.yml++ # ==========================+ # Handle RC Tags+ # ==========================+ release-flow:+ name: Handle RC Tags+ runs-on: ubuntu-latest+ needs: run-tests+ permissions:+ contents: write+ strategy:+ fail-fast: true+ outputs:+ tag: ${{ steps.version.outputs.TAG }}++ steps:+ - name: Checkout Repository+ uses: actions/checkout@v4++ - name: Ensure VERSION file exists+ run: |+ VERSION_FILE="VERSION"+ if [ ! -f "$VERSION_FILE" ]; then+ echo "0.1.0" > "$VERSION_FILE"+ fi++ - name: Fetch full git history and tags+ run: |+ git fetch --unshallow --tags || git fetch --tags++ - name: Bump version+ id: version+ run: |+ VERSION_FILE="VERSION"+ CURRENT_VERSION=$(cat $VERSION_FILE)+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"++ # Update patch version (no manual bump)+ # Tag is X.X.X.RC+ PATCH=$((PATCH + 1))++ NEW_VERSION="$MAJOR.$MINOR.$PATCH"+ TAG="$NEW_VERSION.RC"++ echo "::notice::Release Tag: $TAG"++ echo "$NEW_VERSION" > $VERSION_FILE+ echo "TAG=$TAG" >> $GITHUB_OUTPUT++ - name: Commit updated VERSION file and manifest+ uses: stefanzweifel/git-auto-commit-action@v5+ with:+ commit_message: 'chore: bump version to ${{ steps.version.outputs.TAG }}'+ file_pattern: |+ VERSION++ - name: Create and push Git tag+ if: steps.version.outputs.TAG != ''+ env:+ TAG: ${{ steps.version.outputs.TAG }}+ run: |+ git config user.name "github-actions[bot]"+ git config user.email "github-actions[bot]@users.noreply.github.com"++ if git rev-parse "$TAG" >/dev/null 2>&1; then+ echo "Tag already exists."+ exit 0+ fi++ git tag ${{ steps.version.outputs.TAG }}+ git push origin ${{ steps.version.outputs.TAG }}