name: 'Build and Prepare Release Archive' on: workflow_call: inputs: artifact-name: description: 'The artifact name to use when uploading the preview archive.' default: 'preview-build' required: false type: string preview: description: 'Whether the release is a preview release or not.' default: true required: false type: boolean jobs: release-build: name: 'Build and Prepare Release' permissions: contents: read runs-on: ubuntu-latest steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: 'PHP Build' uses: FOSSBilling/.workflows/.github/actions/php-build@11c3d3bb2ce6915aa0fc8af3165402a65400b084 with: cache-deps: 'false' composer-args: '--prefer-dist --no-dev --optimize-autoloader' php-version: 8.3 - name: 'Install Node.js and Enable Caching' uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 with: cache: 'npm' cache-dependency-path: '**/package-lock.json' node-version: 24 - name: 'Install Node.js Dependencies' run: npm install - name: 'Build Frontend Assets' run: NODE_ENV=production npm run build - name: 'Download Latest Translations' run: | wget https://github.com/FOSSBilling/locale/releases/latest/download/translations.zip -O translations.zip mkdir -p ./src/locale unzip -o translations.zip -d ./src/locale - name: 'Copy Required Files and Clean-up' run: | cp README.md ./src/ cp LICENSE ./src/ rm translations.zip rm -rf ./src/themes/admin_default/node_modules/ - name: 'Add Short Commit Hash as the Release Vesion' if: ${{ inputs.preview }} run: sed -i s/0.0.1/${GITHUB_SHA::7}/ Version.php working-directory: ./src/library/FOSSBilling - name: 'Add the Branch/Tag Name as the Release Version' if: ${{ inputs.preview == false }} run: sed -i s/0.0.1/${{ github.ref_name }}/ Version.php working-directory: ./src/library/FOSSBilling - name: 'Add the Sentry DSN' if: ${{ vars.SENTRY_DSN }} run: | d=$'\03' sed -i "s${d}--replace--this--during--release--process--${d}$SENTRY_DSN$d" SentryHelper.php working-directory: ./src/library/FOSSBilling env: SENTRY_DSN: ${{ vars.SENTRY_DSN }} - name: 'Correct the file & folder permissions' run: | cd ./src/ find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; - name: 'Create Release Build Archive' run: tar -cvf /tmp/build.tar -C ./src/ ./ - name: 'Upload Release Build Archive' uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 with: if-no-files-found: 'error' name: ${{ inputs.artifact-name }} path: /tmp/build.tar retention-days: 1