From 7441dba8696616016e7689c1ff393799b4be2eb0 Mon Sep 17 00:00:00 2001 From: Exelo Date: Thu, 4 Jun 2026 22:13:42 +0900 Subject: [PATCH] ci: add new release workflow --- .github/CODEOWNERS | 2 +- .github/actions/docker-push/action.yml | 20 +++++- .github/actions/pnpm-install/action.yml | 6 ++ .github/workflows/alpha-release.yml | 35 +++++++++ .github/workflows/pre-release.yml | 14 ++-- .github/workflows/release-tag.yml | 35 --------- .github/workflows/release.yml | 96 +++++++++++++++++++++---- Dockerfile | 6 ++ 8 files changed, 151 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/alpha-release.yml delete mode 100644 .github/workflows/release-tag.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index de18624..2de52ae 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @Exeloo @bill-h4rper +* @Exeloo @bill-h4rper @Tchips46 diff --git a/.github/actions/docker-push/action.yml b/.github/actions/docker-push/action.yml index d9cddec..e9ebfa2 100644 --- a/.github/actions/docker-push/action.yml +++ b/.github/actions/docker-push/action.yml @@ -1,6 +1,12 @@ name: docker-push description: Push Docker image on registry inputs: + target: + description: Target name + required: true + args: + description: Arguments to pass to docker build + required: false registry: description: Docker registry required: true @@ -13,9 +19,16 @@ inputs: github-token: description: Github token required: true + config-file: + description: Path to config file + required: true runs: using: composite steps: + - name: Fetch all history for all tags + run: git fetch --prune --unshallow + shell: bash + - name: Determine latest tag id: tag shell: bash @@ -45,6 +58,7 @@ runs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: ${{ inputs.args }} - name: checkout cloud for tags update uses: actions/checkout@v6 @@ -65,8 +79,8 @@ runs: shell: sh run: | cd cloud-iac - python -m yq -Y --indentless --in-place '.image.tag = "${{ steps.tag.outputs.tag }}"' kubernetes/nanoforge/editor-override.yaml + python -m yq -Y --indentless --in-place '.image.tag = "${{ steps.tag.outputs.tag }}"' ${{ inputs.config-file }} - git add kubernetes/nanoforge/editor-override.yaml || echo "No changes to add" - git commit -m "chore(editor): release docker nanoforge-dev/editor@${{ steps.tag.outputs.tag }}" || echo "No changes to commit" + git add ${{ inputs.config-file }} || echo "No changes to add" + git commit -m "chore(${{ inputs.target }}): release docker nanoforge-dev/${{ inputs.target }}@${{ steps.tag.outputs.tag }}" || echo "No changes to commit" git push || echo "No changes to push" diff --git a/.github/actions/pnpm-install/action.yml b/.github/actions/pnpm-install/action.yml index 7d3657f..a2daabb 100644 --- a/.github/actions/pnpm-install/action.yml +++ b/.github/actions/pnpm-install/action.yml @@ -1,5 +1,9 @@ name: 'pnpm install' description: 'Run pnpm install with cache enabled' +inputs: + path: + description: 'Path to the directory containing the pnpm workspace' + default: '.' runs: using: 'composite' steps: @@ -13,6 +17,7 @@ runs: name: Install pnpm with: run_install: false + package_json_file: ${{ inputs.path }}/package.json - name: Expose pnpm config(s) through "$GITHUB_OUTPUT" id: pnpm-config @@ -40,3 +45,4 @@ runs: pnpm install --frozen-lockfile --prefer-offline --loglevel error env: HUSKY: '0' + working-directory: ${{ inputs.path }} diff --git a/.github/workflows/alpha-release.yml b/.github/workflows/alpha-release.yml new file mode 100644 index 0000000..31db1ed --- /dev/null +++ b/.github/workflows/alpha-release.yml @@ -0,0 +1,35 @@ +name: Alpha Release + +on: + workflow_dispatch: + inputs: + dry_run: + description: Perform a dry run? + type: boolean + default: false + +permissions: + contents: write + id-token: write + +jobs: + alpha-release: + name: Alpha release + runs-on: ubuntu-latest + if: github.repository_owner == 'NanoForge-dev' && github.ref_name != 'main' && github.ref_name != 'master' + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Prepare + uses: ./.github/actions/prepare + + - name: Release alpha + uses: ./node_modules/@nanoforge-dev/actions/actions/release-dev + with: + package: '@nanoforge-dev/editor' + tag: alpha + dry: ${{ inputs.dry_run }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 8273a67..1911e35 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -4,9 +4,9 @@ on: workflow_dispatch: inputs: version: - description: 'New version of the package (leave empty for auto generated version)' + description: New version for the packages type: string - required: false + required: true dry_run: description: Perform a dry run? type: boolean @@ -30,16 +30,12 @@ jobs: - name: Prepare uses: ./.github/actions/prepare - env: - PUBLIC_MODE: ${{ vars.PUBLIC_MODE }} - PUBLIC_PM_URL: ${{ vars.PUBLIC_PM_URL }} - - name: Release packages - uses: ./node_modules/@nanoforge-dev/actions/dist/create-release-pr + - name: Create release PR + uses: ./node_modules/@nanoforge-dev/actions/actions/create-packages-release-pr with: - package: '@nanoforge-dev/editor' + packages: '@nanoforge-dev/editor' version: ${{ inputs.version }} dry: ${{ inputs.dry_run }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GIT_REPO: ${{ github.repository }} diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml deleted file mode 100644 index 8e92df5..0000000 --- a/.github/workflows/release-tag.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Release Tag - -on: - pull_request: - types: - - closed - branches: - - main - -permissions: - contents: write - -jobs: - create-release-tag: - name: Create release tag - runs-on: ubuntu-latest - if: github.repository_owner == 'NanoForge-dev' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/') - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - - name: Prepare - uses: ./.github/actions/prepare - env: - PUBLIC_MODE: ${{ vars.PUBLIC_MODE }} - PUBLIC_PM_URL: ${{ vars.PUBLIC_PM_URL }} - - - name: Create release tag - uses: ./node_modules/@nanoforge-dev/actions/dist/create-release-tag - with: - commit: ${{ github.sha }} - branch: ${{ github.head_ref }} - format: '{version}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1bd5b12..51a60b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,11 @@ name: Release on: - workflow_dispatch: - inputs: - dry_run: - description: Perform a dry run? - type: boolean - default: false + pull_request: + types: + - closed + branches: + - main env: REGISTRY: ghcr.io @@ -21,16 +20,13 @@ permissions: id-token: write jobs: - create-release: - name: Create release + release: + name: Release runs-on: ubuntu-latest - if: github.repository_owner == 'NanoForge-dev' + if: github.repository_owner == 'NanoForge-dev' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/') steps: - name: Checkout repository uses: actions/checkout@v6 - with: - fetch-depth: 0 - fetch-tags: true - name: Prepare uses: ./.github/actions/prepare @@ -39,19 +35,89 @@ jobs: PUBLIC_PM_URL: ${{ vars.PUBLIC_PM_URL }} - name: Release packages - uses: ./node_modules/@nanoforge-dev/actions/dist/release-packages + uses: ./node_modules/@nanoforge-dev/actions/actions/release-packages + with: + packages: '@nanoforge-dev/editor' + tag-format: '{version}' + latest: true + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + beta-release: + name: Beta release + runs-on: ubuntu-latest + if: github.repository_owner == 'NanoForge-dev' && github.event.pull_request.merged == true && !startsWith(github.head_ref, 'releases/') + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Prepare + uses: ./.github/actions/prepare + + - name: Release beta + uses: ./node_modules/@nanoforge-dev/actions/actions/release-dev with: package: '@nanoforge-dev/editor' - dry: ${{ inputs.dry_run }} - format: '{version}' + tag: beta env: NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + push-image: + name: Push image + runs-on: ubuntu-latest + if: github.repository_owner == 'NanoForge-dev' + needs: [release] + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + fetch-tags: true + - name: Push Docker image uses: ./.github/actions/docker-push with: + target: editor registry: ${{ env.REGISTRY }} image: ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }} token: ${{ secrets.TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }} + config-file: ${{ env.CONFIG_FILE }} + args: | + PUBLIC_MODE + PUBLIC_PM_URL + env: + PUBLIC_MODE: ONLINE + PUBLIC_PM_URL: https://projects.nanoforge.eu + + publish-docs: + name: Publish docs + runs-on: ubuntu-latest + if: github.repository_owner == 'NanoForge-dev' + needs: [push-image] + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Checkout docs repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + fetch-tags: true + path: docs-dist + repository: nanoforge-dev/docs + token: ${{ secrets.ACTIONS_KEY }} + + - name: Prepare + uses: ./.github/actions/prepare + + - name: Publish docs + uses: ./node_modules/@nanoforge-dev/actions/actions/synchronize-docs + with: + repository: editor + category: editor diff --git a/Dockerfile b/Dockerfile index 4476e70..6f563b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,12 @@ WORKDIR /app FROM base AS prod +ARG PUBLIC_MODE +ARG PUBLIC_PM_URL + +ENV PUBLIC_MODE=${PUBLIC_MODE} +ENV PUBLIC_PM_URL=${PUBLIC_PM_URL} + RUN pnpm install --frozen-lockfile COPY . /app RUN pnpm run build