From b229868e8d3bd2fa4acb94bc7c0db8e02fb4ca76 Mon Sep 17 00:00:00 2001 From: Quentin Goinaud Date: Tue, 24 Dec 2024 09:50:03 +0100 Subject: [PATCH] update CI --- .github/workflows/app-construct-plugin.yml | 109 +++++++++++ .github/workflows/apps-desktop.yml | 112 +++++++++++ .github/workflows/lib-core.yml | 63 +++++++ .github/workflows/push.yml | 207 --------------------- 4 files changed, 284 insertions(+), 207 deletions(-) create mode 100644 .github/workflows/app-construct-plugin.yml create mode 100644 .github/workflows/apps-desktop.yml create mode 100644 .github/workflows/lib-core.yml delete mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/app-construct-plugin.yml b/.github/workflows/app-construct-plugin.yml new file mode 100644 index 0000000..0830236 --- /dev/null +++ b/.github/workflows/app-construct-plugin.yml @@ -0,0 +1,109 @@ +name: Build and Release +on: + push: + tags: + - '**' + branches: + - '**' + +jobs: + build-and-release: + permissions: + contents: write + discussions: write + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + + - uses: pnpm/action-setup@v4 + + - name: Install dependencies and build + run: | + pnpm install + pnpm run build + + # - name: Auto Generate Documentation + # run: | + # pnpm run doc + + # - name: Commit Documentation + # run: | + # git config --global user.email "github-actions[bot]@users.noreply.github.com" + # git config --global user.name "GitHub Actions" + # if [[ -n $(git status -s) ]]; then + # git add README.md + # git commit -m "Update Readme.md" + # else + # echo "No changes to commit" + # fi + + # - name: Push Documentation + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: main + + # - name: Get last modified file + # id: getfile + # run: | + # last_modified_file=$(ls -Art dist | tail -n 1) + # echo "Last modified file: $last_modified_file" + # echo "filename=$last_modified_file" >> $GITHUB_OUTPUT + # version=$(echo $last_modified_file | sed -n 's/.*-\([0-9.]*\).c3addon/\1/p') + # echo "Last modified file version: $version" + # echo "version=$version" >> $GITHUB_OUTPUT + + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: dist/**/* + + # - name: Check if variables are set + # id: check + # run: | + # publish=true + # if [[ -z "${{ secrets.C3_AUTH_USER }}" ]]; then + # echo "C3 AUTH_USER is not set. skip publishing." + # publish=false + # fi + # if [[ -z "${{ secrets.C3_AUTH_PASSWORD }}" ]]; then + # echo "C3 AUTH_PASSWORD is not set. skip publishing." + # publish=false + # fi + # echo "publish=$publish" >> $GITHUB_OUTPUT + + # - name: Install publish dependencies + # if: steps.check.outputs.publish == 'true' + # run: | + # npm install -g c3addon + + # - name: Get Addon Url + # if: steps.check.outputs.publish == 'true' + # id: url + # run: | + # url=$(grep -oP 'addonUrl:\s?"\K[^"]*' src/pluginConfig.js | cut -d '"' -f 1) + # echo "Addon Url: $url" + # if [[ -z "$url" ]]; then + # echo "Addon Url is not set. skip publishing." + # exit 1 + # fi + # echo "url=$url" >> $GITHUB_OUTPUT + + # - name: Publish to Construct 3 + # if: steps.check.outputs.publish == 'true' + # run: | + # c3addon publish \ + # --addonUrl '${{steps.url.outputs.url}}' \ + # --authUser ${{ secrets.C3_AUTH_USER }} \ + # --authPassword ${{ secrets.C3_AUTH_PASSWORD }} \ + # --uploadFile dist/${{ steps.getfile.outputs.filename }} \ + # --version ${{ steps.getfile.outputs.version }} \ + # --releaseNotes 'Released via GitHub Actions' diff --git a/.github/workflows/apps-desktop.yml b/.github/workflows/apps-desktop.yml new file mode 100644 index 0000000..1c4ccbf --- /dev/null +++ b/.github/workflows/apps-desktop.yml @@ -0,0 +1,112 @@ +name: Electron Forge CI/CD + +on: + push: + tags: + - '**' + branches: + - '**' + # pull_request: + # branches: [main] + # merge_group: + +jobs: + build-and-test: + runs-on: ${{ matrix.os }} + env: + CI: true + + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + run_install: false + + - name: Use Node.js 22.5.1 + uses: actions/setup-node@v4 + with: + node-version: '22.5.1' + cache: 'pnpm' + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install dependencies + run: pnpm install + + - name: Build app deps + run: pnpm turbo run build --filter=...@pipelab/app^ + + - name: Package application + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SUPABASE_URL: ${{ secrets.SUPABASE_URL }} + SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} + SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }} + run: pnpm electron-forge publish --dry-run + + - name: Run tests + uses: coactions/setup-xvfb@v1 + with: + run: pnpm test:e2e:raw + + - name: Upload Playwright artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.os }}-playwright + path: playwright/**/* + + - name: Upload artifacts + if: success() + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.os }}-out + path: out/**/* + + release: + permissions: + contents: write + discussions: write + needs: build-and-test + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.os }}-out + path: out + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + run_install: false + + - name: Use Node.js 22.5.1 + uses: actions/setup-node@v4 + with: + node-version: '22.5.1' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --prod=false + + - name: Publish release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: pnpm electron-forge publish --from-dry-run diff --git a/.github/workflows/lib-core.yml b/.github/workflows/lib-core.yml new file mode 100644 index 0000000..de0c03b --- /dev/null +++ b/.github/workflows/lib-core.yml @@ -0,0 +1,63 @@ +name: Node.js Package to npm and gpr + +# trigger when a release is created +on: + push: + tags: + - "**" + branches: + - "**" + +jobs: + build: + permissions: + contents: read + id-token: write + packages: write + attestations: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "22.x" + - uses: pnpm/action-setup@v4 + - run: pnpm install + - run: pnpm test + + # publish to npm + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "22.x" + registry-url: https://registry.npmjs.org/ + - uses: pnpm/action-setup@v4 + - run: pnpm npm install + - run: pnpm npm run build + # - run: pnpm npm run test + - run: pnpm npm publish + if: github.ref == 'refs/tags/v*' + env: + NODE_AUTH_TOKEN: ${{secrets.PUBLISH_NPM_TOKEN}} + + # publish to gpr + # publish-gpr: + # needs: build + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-node@v4 + # with: + # node-version: "22.x" + # registry-url: https://npm.pkg.github.com/ + # scope: "@cyn" + # - uses: pnpm/action-setup@v4 + # - run: pnpm install + # - run: pnpm run build + # - run: pnpm publish + # env: + # NODE_AUTH_TOKEN: ${{secrets.PUBLISH_GITHUB_TOKEN}} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index 37b1a91..0000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,207 +0,0 @@ -name: Electron Forge CI/CD - -on: - push: - tags: - - '**' - branches: - - '**' - pull_request: - branches: [main] - merge_group: - -jobs: - install: - env: - CI: true - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: pnpm/action-setup@v4 - name: Install pnpm - with: - run_install: false - - - name: Use Node.js 22.5.1 - uses: actions/setup-node@v4 - with: - node-version: '22.5.1' - cache: 'pnpm' - - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - - name: Install dependencies - run: pnpm install - - build-and-publish-c3: - runs-on: ubuntu-latest - needs: install - steps: - - name: Auto Generate Documentation - run: | - pnpm run doc - - - name: Commit Documentation - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "GitHub Actions" - if [[ -n $(git status -s) ]]; then - git add README.md - git commit -m "Update Readme.md" - else - echo "No changes to commit" - fi - - - name: Push Documentation - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: main - - - name: Get last modified file - id: getfile - run: | - last_modified_file=$(ls -Art dist | tail -n 1) - echo "Last modified file: $last_modified_file" - echo "filename=$last_modified_file" >> $GITHUB_OUTPUT - version=$(echo $last_modified_file | sed -n 's/.*-\([0-9.]*\).c3addon/\1/p') - echo "Last modified file version: $version" - echo "version=$version" >> $GITHUB_OUTPUT - - - name: Release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - files: dist/**/* - - - name: Check if variables are set - id: check - run: | - publish=true - if [[ -z "${{ secrets.C3_AUTH_USER }}" ]]; then - echo "C3 AUTH_USER is not set. skip publishing." - publish=false - fi - if [[ -z "${{ secrets.C3_AUTH_PASSWORD }}" ]]; then - echo "C3 AUTH_PASSWORD is not set. skip publishing." - publish=false - fi - echo "publish=$publish" >> $GITHUB_OUTPUT - - - name: Install publish dependencies - if: steps.check.outputs.publish == 'true' - run: | - npm install -g c3addon - - - name: Get Addon Url - if: steps.check.outputs.publish == 'true' - id: url - run: | - url=$(grep -oP 'addonUrl:\s?"\K[^"]*' src/pluginConfig.js | cut -d '"' -f 1) - echo "Addon Url: $url" - if [[ -z "$url" ]]; then - echo "Addon Url is not set. skip publishing." - exit 1 - fi - echo "url=$url" >> $GITHUB_OUTPUT - - - name: Publish to Construct 3 - if: steps.check.outputs.publish == 'true' - run: | - c3addon publish \ - --addonUrl '${{steps.url.outputs.url}}' \ - --authUser ${{ secrets.C3_AUTH_USER }} \ - --authPassword ${{ secrets.C3_AUTH_PASSWORD }} \ - --uploadFile dist/${{ steps.getfile.outputs.filename }} \ - --version ${{ steps.getfile.outputs.version }} \ - --releaseNotes 'Released via GitHub Actions' - - build-and-test-desktop-app: - runs-on: ${{ matrix.os }} - needs: install - env: - CI: true - - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - name: Package application - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SUPABASE_URL: ${{ secrets.SUPABASE_URL }} - SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} - SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }} - run: pnpm turbo publish:dry - - - name: Run tests - uses: coactions/setup-xvfb@v1 - with: - run: pnpm turbo test:e2e:raw - - - name: Upload Playwright artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.os }}-playwright - path: apps/desktop/playwright/**/* - - - name: Upload artifacts - if: success() - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.os }}-out - path: apps/desktop/out/**/* - - publish-core-to-npm: - needs: install - runs-on: ubuntu-latest - steps: - - run: pnpm run build - - run: pnpm publish - env: - NODE_AUTH_TOKEN: ${{secrets.PUBLISH_NPM_TOKEN}} - - release: - permissions: - contents: write - discussions: write - needs: build-and-test-desktop-app - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - if: startsWith(github.ref, 'refs/tags/') - - steps: - - uses: actions/checkout@v4 - - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: ${{ matrix.os }}-out - path: out - - - uses: pnpm/action-setup@v4 - name: Install pnpm - with: - run_install: false - - - name: Use Node.js 22.5.1 - uses: actions/setup-node@v4 - with: - node-version: '22.5.1' - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install --prod=false - - - name: Publish release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: pnpm electron-forge publish --from-dry-run