diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ab17ee2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build +on: + workflow_call: + inputs: + artifact_name: + description: Name of uploaded artifact + required: true + type: string +jobs: + www: + name: www + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + uses: ./.github/workflows/www/setup + - name: Build + # Linting is validated in separate workflow + run: yarn build --no-lint + working-directory: packages/www + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact_name }} + path: packages/www/out diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..29032b7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,47 @@ +name: Deploy +on: + workflow_dispatch: + inputs: + component: + description: Component + options: + - www + required: true + type: choice + version: + description: Version + required: true + type: string +permissions: + id-token: write + pages: write +jobs: + download: + name: Download + runs-on: ubuntu-latest + steps: + - name: Download release artifact + uses: robinraju/release-downloader@v1.9 + with: + extract: true + fileName: ${{ inputs.component }}-${{ inputs.version }}.zip + tag: ${{ inputs.component }}-${{ inputs.version }} + - name: List Files + run: ls -R + - name: Delete release artifact + run: rm ${{ inputs.component }}-${{ inputs.version }}.zip + - name: List Files + run: ls -R + - name: Upload workflow artifact + uses: actions/upload-pages-artifact@v3 + deploy: + name: Deploy + environment: + name: github-pages + url: ${{ steps.deploy.outputs.page_url }} + runs-on: ubuntu-latest + needs: download + steps: + - name: Deploy + id: deploy + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..9aa4425 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,15 @@ +name: Format +on: + workflow_call: +jobs: + www: + name: www + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + uses: ./.github/workflows/www/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..46cfcb0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,15 @@ +name: Lint +on: + workflow_call: +jobs: + www: + name: www + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + uses: ./.github/workflows/www/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..3252edc --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,18 @@ +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 + with: + artifact_name: www diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml new file mode 100644 index 0000000..2c6c6bb --- /dev/null +++ b/.github/workflows/push-main.yml @@ -0,0 +1,47 @@ +name: Push main +on: + push: + branches: main +permissions: + contents: write + pull-requests: write +jobs: + release: + name: Release + runs-on: ubuntu-latest + outputs: + artifact_name: www-${{ steps.release.outputs['packages/www--major'] }}.${{ steps.release.outputs['packages/www--minor'] }}.${{ steps.release.outputs['packages/www--patch'] }} + release_tag: ${{ steps.release.outputs['packages/www--tag_name'] }} + releases_created: ${{ steps.release.outputs.releases_created }} + steps: + - uses: google-github-actions/release-please-action@v4 + id: release + with: + config-file: release-config.json + manifest-file: release-manifest.json + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + format: + name: Format + needs: release + if: needs.release.outputs.releases_created == 'true' + uses: ./.github/workflows/format.yml + lint: + name: Lint + needs: release + if: needs.release.outputs.releases_created == 'true' + uses: ./.github/workflows/lint.yml + build: + name: Build + needs: [format, lint, release] + if: needs.release.outputs.releases_created == 'true' + uses: ./.github/workflows/build.yml + with: + artifact_name: ${{ needs.release.outputs.artifact_name }} + upload-release-artifact: + name: Upload release artifact + needs: [build, release] + if: needs.release.outputs.releases_created == 'true' + uses: ./.github/workflows/upload-release-artifact.yml + with: + artifact_name: ${{ needs.release.outputs.artifact_name }} + release_tag: ${{ needs.release.outputs.release_tag }} diff --git a/.github/workflows/upload-release-artifact.yml b/.github/workflows/upload-release-artifact.yml new file mode 100644 index 0000000..597dc85 --- /dev/null +++ b/.github/workflows/upload-release-artifact.yml @@ -0,0 +1,30 @@ +name: Upload release artifact +on: + workflow_call: + inputs: + artifact_name: + description: Workflow artifact to upload + required: true + type: string + release_tag: + description: Release tag to upload to + required: true + type: string +jobs: + www: + name: www + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download workflow artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact_name }} + path: ${{ inputs.artifact_name }} + - name: Compress & package artifact + run: (cd ${{ inputs.artifact_name }} && zip -r "$OLDPWD/${{ inputs.artifact_name }}.zip" .) + - name: Upload release artifact + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload ${{ inputs.release_tag }} ${{ inputs.artifact_name }}.zip diff --git a/.github/workflows/www/setup/action.yml b/.github/workflows/www/setup/action.yml new file mode 100644 index 0000000..305d82d --- /dev/null +++ b/.github/workflows/www/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-config.json b/release-config.json new file mode 100644 index 0000000..8c801d5 --- /dev/null +++ b/release-config.json @@ -0,0 +1,9 @@ +{ + "include-v-in-tag": false, + "packages": { + "packages/www": { + "package-name": "www" + } + }, + "pull-request-header": ":rocket: In the Next Release..." +} diff --git a/release-manifest.json b/release-manifest.json new file mode 100644 index 0000000..10d5ebc --- /dev/null +++ b/release-manifest.json @@ -0,0 +1,3 @@ +{ + "packages/www": "1.0.0" +}