|
| 1 | +name: Beta |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Test"] |
| 6 | + types: [completed] |
| 7 | + push: |
| 8 | + branches: ["beta"] |
| 9 | + pull_request: |
| 10 | + branches: ["beta"] |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + if: > |
| 18 | + github.event.workflow_run.conclusion == 'success' && |
| 19 | + github.event.workflow_run.head_branch == 'beta' |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Setup PHP |
| 28 | + uses: shivammathur/setup-php@v2 |
| 29 | + with: |
| 30 | + php-version: '8.3' |
| 31 | + extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, iconv, json, mbstring, pdo |
| 32 | + |
| 33 | + - name: Validate version |
| 34 | + id: version |
| 35 | + run: | |
| 36 | + VERSION=$(php -r "echo trim(file_get_contents('VERSION'));") |
| 37 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 38 | + EXISTING=$(git tag | grep -E "^v${VERSION}-beta\.[0-9]+$" | sort -V | tail -n 1 || true) |
| 39 | +
|
| 40 | + if [ -z "$EXISTING" ]; then |
| 41 | + NEW_TAG="v${VERSION}-beta.1" |
| 42 | + else |
| 43 | + LAST_NUM=$(echo "$EXISTING" | sed -E 's/^v[0-9]+\.[0-9]+\.[0-9]+-beta\.([0-9]+)$/\1/') |
| 44 | + NEXT_NUM=$((LAST_NUM + 1)) |
| 45 | + NEW_TAG="v${VERSION}-beta.${NEXT_NUM}" |
| 46 | + fi |
| 47 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Check if tag already exists |
| 50 | + run: | |
| 51 | + TAG="v${{ steps.version.outputs.version }}" |
| 52 | + echo "Checking if tag $TAG already exists..." |
| 53 | +
|
| 54 | + if git rev-parse "$TAG" >/dev/null 2>&1; then |
| 55 | + echo "Tag $TAG already exists. Please bump the version before releasing." |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | + echo "Tag $TAG is available." |
| 59 | +
|
| 60 | + - name: Setup Node.js |
| 61 | + uses: actions/setup-node@v4 |
| 62 | + with: |
| 63 | + node-version: '22' |
| 64 | + |
| 65 | + - name: Get composer cache directory |
| 66 | + id: composer-cache |
| 67 | + run: cd app && echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 68 | + |
| 69 | + - name: Cache composer dependencies |
| 70 | + uses: actions/cache@v4 |
| 71 | + with: |
| 72 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 73 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 74 | + restore-keys: ${{ runner.os }}-composer- |
| 75 | + |
| 76 | + - name: Install PHP dependencies |
| 77 | + run: composer install --no-dev --optimize-autoloader --no-interaction |
| 78 | + |
| 79 | + - name: Install pnpm |
| 80 | + run: npm install -g pnpm |
| 81 | + |
| 82 | + - name: Install Node dependencies |
| 83 | + run: pnpm i |
| 84 | + |
| 85 | + - name: Build frontend assets |
| 86 | + run: pnpm run build |
| 87 | + |
| 88 | + - name: Prepare release |
| 89 | + run: | |
| 90 | + echo "removing development files..." |
| 91 | + rm -rf tests .github .cache builds .config .local node_modules phpunit.xml eslint.config.js .editorconfig .gitattributes .gitignore .prettierrc .prettierignore resources/css resources/js |
| 92 | + |
| 93 | + echo "cleaning storage directories..." |
| 94 | + find storage -name "*.log" -delete 2>/dev/null || true |
| 95 | + find storage/framework/cache -name "*" -not -name ".gitignore" -delete 2>/dev/null || true |
| 96 | + find storage/framework/sessions -name "*" -not -name ".gitignore" -delete 2>/dev/null || true |
| 97 | + find storage/framework/views -name "*" -not -name ".gitignore" -delete 2>/dev/null || true |
| 98 | +
|
| 99 | + - name: Create archive |
| 100 | + run: zip -r "../dployr-v${{ steps.version.outputs.version }}.zip" . |
| 101 | + |
| 102 | + - name: Create tag |
| 103 | + run: | |
| 104 | + echo "Creating tag..." |
| 105 | + git config user.name "github-actions[bot]" |
| 106 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 107 | + git tag v${{ steps.version.outputs.version }} |
| 108 | + git push origin v${{ steps.version.outputs.version }} |
| 109 | +
|
| 110 | + - name: Create Release |
| 111 | + uses: softprops/action-gh-release@v2 |
| 112 | + with: |
| 113 | + tag_name: v${{ steps.version.outputs.version }} |
| 114 | + name: dployr ${{ steps.version.outputs.version }} |
| 115 | + files: | |
| 116 | + dployr-v${{ steps.version.outputs.version }}.zip |
| 117 | + LICENSE |
| 118 | + generate_release_notes: true |
| 119 | + make_latest: false |
| 120 | + env: |
| 121 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments