From ad69a7681e9ff86c647a0df352810a2947be4ad0 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 22 Jun 2026 23:26:17 -0400 Subject: [PATCH] Build and tag release assets in CI instead of composer-dist-plugin Co-Authored-By: Claude Opus 4.8 --- .gitattributes | 6 ++ .github/workflows/release.yml | 103 +++++++++++++++++++++++++--------- composer.json | 14 +---- 3 files changed, 85 insertions(+), 38 deletions(-) diff --git a/.gitattributes b/.gitattributes index 4082132ee33..20bbc8199a7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,12 @@ * text=auto *.php eol=lf + +/resources/dist/**/* linguist-generated=true +/resources/dist-frontend/**/* linguist-generated=true + /.github export-ignore +/resources/js export-ignore +/resources/css export-ignore /tests export-ignore .babelrc export-ignore .gitattributes export-ignore diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 199e3330529..dfc815e00f5 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. 5.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 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - 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 5.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 16.13.0 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 @@ -30,32 +67,48 @@ jobs: - name: Install dependencies run: npm ci - - name: Compile assets - run: npm run build - - - name: Compile frontend assets - run: npm run frontend-build + - name: Build release assets + run: | + npm run build + npm run frontend-build - - name: Create dist zip - run: cd resources && tar -czvf dist.tar.gz dist + - 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-frontend + git commit -m "Build assets for $TAG" - - name: Create dist-frontend zip - run: cd resources && tar -czvf dist-frontend.tar.gz dist-frontend + - 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-frontend.tar.gz + --latest="$latest" \ + --prerelease="$prerelease" diff --git a/composer.json b/composer.json index 96c07f07d8d..7bfd52b1f4f 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "maennchen/zipstream-php": "^3.1", "michelf/php-smartypants": "^1.8.1", "nesbot/carbon": "^2.62.1 || ^3.0", - "pixelfear/composer-dist-plugin": "^0.1.4", "rebing/graphql-laravel": "^9.8", "rhukster/dom-sanitizer": "^1.0.7", "spatie/blink": "^1.3", @@ -54,21 +53,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-frontend.tar.gz", - "path": "resources/dist-frontend" - } - ], "laravel": { "providers": [ "Statamic\\Providers\\StatamicServiceProvider"