Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
103 changes: 78 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
14 changes: 1 addition & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
Loading