diff --git a/.gitattributes b/.gitattributes index 4082132ee33..887616f4e4f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,15 @@ * text=auto *.php eol=lf + +/resources/dist/**/* linguist-generated=true +/resources/dist-dev/**/* linguist-generated=true +/resources/dist-frontend/**/* linguist-generated=true +/resources/dist-package/**/* linguist-generated=true + /.github export-ignore +/resources/js export-ignore +/resources/css export-ignore +/packages export-ignore /tests export-ignore .babelrc export-ignore .gitattributes export-ignore diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8142160c878..dd0827e9f0f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,22 +1,59 @@ name: Create Release on: # zizmor: ignore[concurrency-limits] - push: - tags: - - 'v*' + workflow_dispatch: + inputs: + version: + description: 'Release version, without the v prefix (e.g. 6.2.0)' + required: true + type: string permissions: {} jobs: - build: # zizmor: ignore[anonymous-definition] + release: + name: Create Release runs-on: ubuntu-latest - permissions: - contents: write # create GitHub release and upload assets + environment: Releases + permissions: {} # all writes go through the App token; GITHUB_TOKEN needs no scopes steps: - - name: Checkout code + - name: Resolve and validate version + env: + INPUT_VERSION: ${{ inputs.version }} + BRANCH: ${{ github.ref_name }} + run: | + version="${INPUT_VERSION#v}" + + if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then + echo "::error::Version must look like 6.2.0 (got: $INPUT_VERSION)" + exit 1 + fi + + if [ "${version%%.*}" != "${BRANCH%%.*}" ]; then + echo "::error::Version $version does not belong on the $BRANCH branch" + exit 1 + fi + + echo "TAG=v$version" >> "$GITHUB_ENV" + + - name: Get release bot token + id: app-token + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + with: + client-id: ${{ secrets.RELEASE_APP_CLIENT_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + permission-contents: write + + - name: Checkout uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: - persist-credentials: false + token: ${{ steps.app-token.outputs.token }} + persist-credentials: true # zizmor: ignore[artipacked] App token is needed to push the tag + + - name: Assert tag does not already exist + run: | + existing="$(git ls-remote --tags origin "$TAG")" + [ -z "$existing" ] || { echo "::error::Tag $TAG already exists on remote. Aborting."; exit 1; } - name: Use Node.js 20.19.0 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 @@ -30,25 +67,48 @@ jobs: - name: Build release assets run: bash ./scripts/build-release.sh + - name: Create the build commit + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + APP_SLUG: ${{ steps.app-token.outputs.app-slug }} + run: | + USER_ID="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)" + git config user.name "${APP_SLUG}[bot]" + git config user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com" + git add --force \ + resources/dist \ + resources/dist-dev \ + resources/dist-frontend \ + resources/dist-package + git commit -m "Build assets for $TAG" + + - name: Tag and push the build commit + run: | + git tag "$TAG" + git push origin "$TAG" + - name: Get Changelog id: changelog uses: statamic/changelog-action@5d112d0d790cdeeb5adca3e584e37edc474ab51b # v1.0.2 with: - version: ${{ github.ref }} + version: ${{ env.TAG }} - name: Create release env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_VERSION: ${{ steps.changelog.outputs.version }} + GH_TOKEN: ${{ steps.app-token.outputs.token }} RELEASE_NOTES: ${{ steps.changelog.outputs.text }} + IS_DEFAULT_BRANCH: ${{ github.ref_name == github.event.repository.default_branch }} run: | - gh release create "$RELEASE_VERSION" \ - --title "$RELEASE_VERSION" \ + latest="$IS_DEFAULT_BRANCH" + prerelease=false + case "$TAG" in + *-*) prerelease=true; latest=false ;; + esac + gh release create "$TAG" \ + --title "$TAG" \ --notes "$RELEASE_NOTES" \ - ./resources/dist.tar.gz \ - ./resources/dist-dev.tar.gz \ - ./resources/dist-frontend.tar.gz \ - ./resources/dist-package.tar.gz + --latest="$latest" \ + --prerelease="$prerelease" - name: Deploy Storybook to Forge continue-on-error: true diff --git a/composer.json b/composer.json index b287fe28eb7..910d28b14e1 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,6 @@ "maennchen/zipstream-php": "^3.1", "michelf/php-smartypants": "^1.8.1", "nesbot/carbon": "^3.0", - "pixelfear/composer-dist-plugin": "^0.1.4", "pragmarx/google2fa": "^8.0 || ^9.0", "rebing/graphql-laravel": "^9.15", "rhukster/dom-sanitizer": "^1.0.10", @@ -63,29 +62,10 @@ "preferred-install": "dist", "sort-packages": true, "allow-plugins": { - "composer/package-versions-deprecated": true, - "pixelfear/composer-dist-plugin": true + "composer/package-versions-deprecated": true } }, "extra": { - "download-dist": [ - { - "url": "https://github.com/statamic/cms/releases/download/{$version}/dist.tar.gz", - "path": "resources/dist" - }, - { - "url": "https://github.com/statamic/cms/releases/download/{$version}/dist-dev.tar.gz", - "path": "resources/dist-dev" - }, - { - "url": "https://github.com/statamic/cms/releases/download/{$version}/dist-frontend.tar.gz", - "path": "resources/dist-frontend" - }, - { - "url": "https://github.com/statamic/cms/releases/download/{$version}/dist-package.tar.gz", - "path": "resources/dist-package" - } - ], "laravel": { "providers": [ "Statamic\\Providers\\StatamicServiceProvider" diff --git a/scripts/build-release.sh b/scripts/build-release.sh index dc9f6cacad8..e3af82e2c51 100644 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -10,16 +10,7 @@ npm run build npm run build-dev npm run frontend-build -# Create tarballs for the Laravel package -cd resources -tar -czvf dist.tar.gz dist -tar -czvf dist-dev.tar.gz dist-dev -tar -czvf dist-frontend.tar.gz dist-frontend -cd .. - -# Create a tarball for @statamic/cms +# Populate resources/dist-package from packages/cms cp resources/css/ui.css packages/cms/src/ui.css -cd packages/cms -tar -czvf ../../resources/dist-package.tar.gz * -cd ../.. +rsync -a --delete packages/cms/ resources/dist-package/