diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b37bca4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +on: + workflow_call: + inputs: + upload-artifact: + default: false + description: Whether to upload the build artifact + required: false + type: boolean +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + uses: ./.github/workflows/setup + - name: Build + # Linting has already been validated so skip to improve build speed + run: yarn build --no-lint + working-directory: packages/www + - name: Upload artifact + uses: actions/upload-artifact@v4 + if: ${{ inputs.upload-artifact }} + with: + name: "@philostler.com/www" + path: packages/www/out diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..01e53b8 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,14 @@ +on: + workflow_call: +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + uses: ./.github/workflows/setup + - name: Check formatting + run: yarn format:check + working-directory: packages/www diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0519033 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,14 @@ +on: + workflow_call: +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + uses: ./.github/workflows/setup + - name: Check linting + run: yarn lint:check + working-directory: packages/www diff --git a/.github/workflows/main-push.yml b/.github/workflows/main-push.yml deleted file mode 100644 index 28abcdd..0000000 --- a/.github/workflows/main-push.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: main Push -on: - push: - branches: main -permissions: - contents: read - id-token: write - pages: write -concurrency: - cancel-in-progress: false - group: "pages" -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup - uses: actions/setup-node@v4 - with: - cache-dependency-path: packages/www/yarn.lock - cache: yarn - node-version: 20.11.1 - - name: Cache - uses: actions/cache@v4 - with: - path: packages/www/.next/cache - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} - restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- - - name: Dependencies - run: yarn install - working-directory: packages/www - - name: Format - run: yarn format:check - working-directory: packages/www - - name: Lint - run: yarn lint:check - working-directory: packages/www - - name: Build - run: yarn build - working-directory: packages/www - - name: Upload - uses: actions/upload-pages-artifact@v3 - with: - path: packages/www/out - deploy: - name: Deploy - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy - id: deployment - uses: actions/deploy-pages@v4 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..701e606 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,16 @@ +name: Pull Request +on: + pull_request: + branches: + - "!release-please*/*" +jobs: + format: + name: Format + uses: ./.github/workflows/format.yml + lint: + name: Lint + uses: ./.github/workflows/lint.yml + build: + name: Build + needs: [format, lint] + uses: ./.github/workflows/build.yml diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml new file mode 100644 index 0000000..d989382 --- /dev/null +++ b/.github/workflows/push-main.yml @@ -0,0 +1,37 @@ +name: Push main +on: + push: + branches: main +permissions: + contents: write + pull-requests: write +jobs: + release: + name: Release + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + steps: + - uses: google-github-actions/release-please-action@v4 + id: release + with: + config-file: release-please-config.json + manifest-file: release-please-manifest.json + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + format: + name: Format + needs: release + if: ${{ needs.release.outputs.release_created }} + uses: ./.github/workflows/format.yml + lint: + name: Lint + needs: release + if: ${{ needs.release.outputs.release_created }} + uses: ./.github/workflows/lint.yml + build: + name: Build + needs: [release, format, lint] + if: ${{ needs.release.outputs.release_created }} + uses: ./.github/workflows/build.yml + with: + upload-artifact: true diff --git a/.github/workflows/setup/action.yml b/.github/workflows/setup/action.yml new file mode 100644 index 0000000..305d82d --- /dev/null +++ b/.github/workflows/setup/action.yml @@ -0,0 +1,22 @@ +name: Setup +runs: + using: composite + steps: + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + cache: yarn + cache-dependency-path: packages/www/yarn.lock + node-version-file: packages/www/package.json + - name: Restore Next.js build cache + uses: actions/cache@v4 + with: + path: packages/www/.next/cache + # Generate a new cache whenever packages or source files change + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} + # If source files changed but packages didn't, rebuild from a prior cache + restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- + - name: Install dependencies + run: yarn install + shell: bash + working-directory: packages/www diff --git a/packages/www/.prettierignore b/packages/www/.prettierignore index a680367..81c0689 100644 --- a/packages/www/.prettierignore +++ b/packages/www/.prettierignore @@ -1 +1,3 @@ .next + +CHANGELOG.md diff --git a/packages/www/package.json b/packages/www/package.json index 87f1d20..f69eee5 100644 --- a/packages/www/package.json +++ b/packages/www/package.json @@ -1,5 +1,5 @@ { - "name": "www.philostler.com", + "name": "@philostler.com/www", "version": "1.0.0", "private": true, "scripts": { diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..1c14f83 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,11 @@ +{ + "packages": { + "packages/www": {} + }, + "plugins": [ + { + "type": "sentence-case" + } + ], + "pull-request-header": ":robot: Release Please says *\"I have created a new release\"*" +} diff --git a/release-please-manifest.json b/release-please-manifest.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/release-please-manifest.json @@ -0,0 +1 @@ +{}