diff --git a/.github/workflows/ppe.yaml b/.github/workflows/ppe.yaml index 7b7b7aaf3..7bc85293d 100644 --- a/.github/workflows/ppe.yaml +++ b/.github/workflows/ppe.yaml @@ -1,25 +1,37 @@ -name: "PPE" +name: 'Publish dev artifacts (latest dev)' on: push: branches: - main +permissions: + contents: read + jobs: unit_tests_linux: name: Verify Tests (Linux) - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Read .nvmrc - run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')" - id: nvm + - name: Extract node version from package.json + uses: sergeysova/jq-action@v2 + id: node_version + with: + cmd: jq .engines.node package.json -r | sed -e 's/"//g' | sed -e 's/>=//g' + - name: Extract yarn version from package.json + uses: sergeysova/jq-action@v2 + id: yarn_version + with: + cmd: jq .engines.yarn package.json -r | sed -e 's/"//g' - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + node-version: '${{ steps.node_version.outputs.value }}' + - name: Use Yarn + run: corepack enable && corepack prepare --activate yarn@${{ steps.yarn_version.outputs.value }} - name: Install deps run: yarn - name: Prepare @@ -33,18 +45,31 @@ jobs: package_for_ppe_linux: name: Package for PPE (Linux) - runs-on: self-hosted + runs-on: ubuntu-latest + permissions: + packages: write + env: + REGISTRY: ghcr.io steps: - uses: actions/checkout@v4 with: fetch-depth: 2 - - name: Read .nvmrc - run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')" - id: nvm + - name: Extract node version from package.json + uses: sergeysova/jq-action@v2 + id: node_version + with: + cmd: jq .engines.node package.json -r | sed -e 's/"//g' | sed -e 's/>=//g' + - name: Extract yarn version from package.json + uses: sergeysova/jq-action@v2 + id: yarn_version + with: + cmd: jq .engines.yarn package.json -r | sed -e 's/"//g' - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + node-version: '${{ steps.node_version.outputs.value }}' + - name: Use Yarn + run: corepack enable && corepack prepare --activate yarn@${{ steps.yarn_version.outputs.value }} - name: Install deps run: yarn - name: Prepare @@ -53,61 +78,26 @@ jobs: ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - - - name: Package apps - run: yarn nx run-many --target=package --parallel --verbose --projects=tag:linux + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY}} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Publish apps + run: yarn nx affected --target=publish --parallel --base=HEAD~ --head=HEAD --verbose env: ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} NODE_ENV: production + TAG: ${{ env.REGISTRY }}/${{ github.repository }}:game-db-updater-dev - name: Upload artifacts uses: actions/upload-artifact@v3 with: name: packaged-apps path: apps/*/.packaged - deploy_ppe: - name: Deploy affected to PPE - runs-on: self-hosted - needs: - - unit_tests_linux - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 - ref: main - - name: Read Node version - run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')" - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" - - uses: actions/setup-dotnet@v2 - with: - dotnet-version: "7.0.403" - - name: Install deps - run: yarn - - name: Prepare - run: yarn nx run-many --target=prepare --parallel --all - env: - ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} - ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} - ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - - - name: Deploy affected apps - run: yarn nx affected --target=deploy --parallel --verbose --projects=tag:linux - env: - CODECOV_TOKEN: ${{ secrets.CODE_COV_TOKEN }} - ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} - ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} - ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - MQTT_HOST: ${{ secrets.K8S_MAIN_NODE_IP }} - MQTT_PORT: ${{ secrets.MQTT_PORT_EXTERNAL }} - MQTT_USERNAME: ${{ secrets.MQTT_USERNAME }} - MQTT_PASSWORD: ${{ secrets.MQTT_PASSWORD }} - NODE_ENV: production - unit_tests_windows: name: Verify PR - Tests (Windows) runs-on: windows-latest @@ -123,7 +113,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + node-version: '${{ steps.nvm.outputs.NODE_VERSION }}' - name: Enable yarn run: corepack enable - run: corepack prepare --activate yarn@^4.0.0 @@ -138,42 +128,42 @@ jobs: - name: Run all unit tests run: yarn nx run-many --target=test/unit --parallel --verbose --projects=tag:windows - package_windows: - name: Package for PPE (Windows) - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - name: Install jq - run: curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe - - name: Read .nvmrc - run: echo "##[set-output name=NODE_VERSION;]20.9.0" - id: nvm - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" - - name: Enable yarn - run: corepack enable - - run: corepack prepare --activate yarn@^4.0.0 - - name: Install deps - run: yarn - - name: Prepare - run: yarn nx run-many --target=prepare --parallel --all --verbose - env: - ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} - ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} - ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - - name: Package apps - run: yarn nx run-many --target=package --parallel --verbose --projects=tag:windows - env: - ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} - ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} - ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - NODE_ENV: production - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: packaged-apps - path: apps/*/.packaged + # package_windows: + # name: Package for PPE (Windows) + # runs-on: windows-latest + # steps: + # - uses: actions/checkout@v4 + # with: + # fetch-depth: 2 + # - name: Install jq + # run: curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe + # - name: Read .nvmrc + # run: echo "##[set-output name=NODE_VERSION;]20.9.0" + # id: nvm + # - name: Use Node.js + # uses: actions/setup-node@v3 + # with: + # node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + # - name: Enable yarn + # run: corepack enable + # - run: corepack prepare --activate yarn@^4.0.0 + # - name: Install deps + # run: yarn + # - name: Prepare + # run: yarn nx run-many --target=prepare --parallel --all --verbose + # env: + # ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} + # ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} + # ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} + # - name: Publish apps + # run: yarn nx affected --target=publish --parallel --base=HEAD~ --head=HEAD --verbose + # env: + # ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} + # ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} + # ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} + # NODE_ENV: production + # - name: Upload artifacts + # uses: actions/upload-artifact@v3 + # with: + # name: packaged-apps + # path: apps/*/.packaged diff --git a/.github/workflows/publish-release.yaml b/.github/workflows/publish-release.yaml index cdfdcfe44..87d814f8b 100644 --- a/.github/workflows/publish-release.yaml +++ b/.github/workflows/publish-release.yaml @@ -3,31 +3,43 @@ name: Release a new version of Playnite-Web on: push: tags: - - "v*.*.*" + - 'v*.*.*' permissions: contents: write - pull-requests: write jobs: release_linux: name: On Release Published needs: [] - - runs-on: self-hosted + permissions: + packages: write + env: + REGISTRY: ghcr.io + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 2 - - name: Read .nvmrc - run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')" - id: nvm + - name: Extract node version from package.json + uses: sergeysova/jq-action@v2 + id: node_version + with: + cmd: jq .engines.node package.json -r | sed -e 's/"//g' | sed -e 's/>=//g' + - name: Extract yarn version from package.json + uses: sergeysova/jq-action@v2 + id: yarn_version + with: + cmd: jq .engines.yarn package.json -r | sed -e 's/"//g' - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + node-version: '${{ steps.node_version.outputs.value }}' + - name: Use Yarn + run: corepack enable && corepack prepare --activate yarn@${{ steps.yarn_version.outputs.value }} + - name: Install deps run: yarn - name: Prepare @@ -36,9 +48,14 @@ jobs: ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - - - name: Package apps - run: yarn nx run-many --target=package --parallel --verbose --projects=tag:linux + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Publish apps + run: yarn nx run-many --target=publish --parallel --verbose --all env: ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} @@ -52,48 +69,48 @@ jobs: LICENSE apps/*/.packaged - release_windows: - name: On Release Published - needs: [] + # release_windows: + # name: On Release Published + # needs: [] - runs-on: windows-latest + # runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - name: Install jq - run: curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe - - name: Read .nvmrc - run: echo "##[set-output name=NODE_VERSION;]20.9.0" - id: nvm - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" - - name: Enable yarn - run: corepack enable - - run: corepack prepare --activate yarn@^4.0.0 - - name: Install deps - run: yarn - - name: Prepare - run: yarn nx run-many --target=prepare --parallel --verbose - env: - ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} - ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} - ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # with: + # fetch-depth: 2 + # - name: Install jq + # run: curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe + # - name: Read .nvmrc + # run: echo "##[set-output name=NODE_VERSION;]20.9.0" + # id: nvm + # - name: Use Node.js + # uses: actions/setup-node@v3 + # with: + # node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + # - name: Enable yarn + # run: corepack enable + # - run: corepack prepare --activate yarn@^4.0.0 + # - name: Install deps + # run: yarn + # - name: Prepare + # run: yarn nx run-many --target=prepare --parallel --verbose + # env: + # ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} + # ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} + # ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - - name: Package apps - run: yarn nx run-many --target=package --parallel --verbose --projects=tag:windows - env: - ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} - ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} - ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - NODE_ENV: production + # - name: Publish apps + # run: yarn nx run-many --target=publish --parallel --verbose --all + # env: + # ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} + # ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} + # ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} + # NODE_ENV: production - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: | - apps/*/.packaged + # - name: Release + # uses: softprops/action-gh-release@v1 + # with: + # files: | + # apps/*/.packaged diff --git a/.github/workflows/pull-request-master-closed.yaml b/.github/workflows/pull-request-master-closed.yaml new file mode 100644 index 000000000..7f30a9fda --- /dev/null +++ b/.github/workflows/pull-request-master-closed.yaml @@ -0,0 +1,25 @@ +name: 'Remove Pull Request Packages' + +on: + pull_request: + types: [closed] + +permissions: + packages: write + +env: + REGISTRY: ghcr.io + +jobs: + retention_policy: + if: github.event.pull_request.merged == true + name: Retention policy + runs-on: ubuntu-latest + steps: + - uses: actions/delete-package-versions@v4 + with: + owner: ${{ github.actor }} + token: ${{ secrets.GITHUB_TOKEN }} + package-type: container + package-name: ${{ env.REGISTRY }}/${{ github.repository }} + ignore-versions: '^([a-z0-9]+-v[0-9]+\.[0-9]+\.[0-9]+)|([a-z0-9]+-PR(?!${{ github.event.pull_request.number }})|([a-z0-9]+-dev))$]' diff --git a/.github/workflows/pull-request-master.yaml b/.github/workflows/pull-request-master.yaml index 8daae24e9..a1f66fefb 100644 --- a/.github/workflows/pull-request-master.yaml +++ b/.github/workflows/pull-request-master.yaml @@ -1,25 +1,38 @@ -name: "Verify Pull Request" +name: 'Verify Pull Request' on: pull_request: branches: - main +permissions: + contents: read + pull-requests: write + jobs: unit_tests_linux: name: Verify PR - Tests (Linxu) - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Read .nvmrc - run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')" - id: nvm + - name: Extract node version from package.json + uses: sergeysova/jq-action@v2 + id: node_version + with: + cmd: jq .engines.node package.json -r | sed -e 's/"//g' | sed -e 's/>=//g' + - name: Extract yarn version from package.json + uses: sergeysova/jq-action@v2 + id: yarn_version + with: + cmd: jq .engines.yarn package.json -r | sed -e 's/"//g' - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + node-version: '${{ steps.node_version.outputs.value }}' + - name: Use Yarn + run: corepack enable && corepack prepare --activate yarn@${{ steps.yarn_version.outputs.value }} - name: Install deps run: yarn - name: Prepare @@ -33,18 +46,31 @@ jobs: package_linux: name: Package (Linux) - runs-on: self-hosted + runs-on: ubuntu-latest + permissions: + packages: write + env: + REGISTRY: ghcr.io steps: - uses: actions/checkout@v4 with: fetch-depth: 2 - - name: Read .nvmrc - run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')" - id: nvm + - name: Extract node version from package.json + uses: sergeysova/jq-action@v2 + id: node_version + with: + cmd: jq .engines.node package.json -r | sed -e 's/"//g' | sed -e 's/>=//g' + - name: Extract yarn version from package.json + uses: sergeysova/jq-action@v2 + id: yarn_version + with: + cmd: jq .engines.yarn package.json -r | sed -e 's/"//g' - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + node-version: '${{ steps.node_version.outputs.value }}' + - name: Use Yarn + run: corepack enable && corepack prepare --activate yarn@${{ steps.yarn_version.outputs.value }} - name: Install deps run: yarn - name: Prepare @@ -53,13 +79,21 @@ jobs: ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - - - name: Package apps - run: yarn nx affected --target=package --parallel --base=HEAD~ --head=HEAD --verbose --projects=tag:linux + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Publish apps + run: yarn nx affected --target=publish --parallel --base=HEAD~ --head=HEAD --verbose env: ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} + TAG: ${{ env.REGISTRY }}/${{ github.repository }}:game-db-updater-PR${{ github.event.pull_request.number }} NODE_ENV: production - name: Upload artifacts uses: actions/upload-artifact@v3 @@ -82,7 +116,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + node-version: '${{ steps.nvm.outputs.NODE_VERSION }}' - name: Enable yarn run: corepack enable - run: corepack prepare --activate yarn@^4.0.0 @@ -97,43 +131,43 @@ jobs: - name: Run all unit tests run: yarn nx run-many --target=test/unit --parallel --verbose --projects=tag:windows - package_windows: - name: Package (Windows) - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - name: Install jq - run: curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe - - name: Read .nvmrc - run: echo "##[set-output name=NODE_VERSION;]20.9.0" - id: nvm - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" - - name: Enable yarn - run: corepack enable - - run: corepack prepare --activate yarn@^4.0.0 - - name: Install deps - run: yarn - - name: Prepare - run: yarn nx run-many --target=prepare --parallel --all --verbose - env: - ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} - ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} - ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} + # package_windows: + # name: Package (Windows) + # runs-on: windows-latest + # steps: + # - uses: actions/checkout@v4 + # with: + # fetch-depth: 2 + # - name: Install jq + # run: curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe + # - name: Read .nvmrc + # run: echo "##[set-output name=NODE_VERSION;]20.9.0" + # id: nvm + # - name: Use Node.js + # uses: actions/setup-node@v3 + # with: + # node-version: "${{ steps.nvm.outputs.NODE_VERSION }}" + # - name: Enable yarn + # run: corepack enable + # - run: corepack prepare --activate yarn@^4.0.0 + # - name: Install deps + # run: yarn + # - name: Prepare + # run: yarn nx run-many --target=prepare --parallel --all --verbose + # env: + # ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} + # ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} + # ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - - name: Package apps - run: yarn nx affected --target=package --parallel --base=HEAD~ --head=HEAD --verbose --projects=tag:windows - env: - ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} - ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} - ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} - NODE_ENV: production - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: packaged-apps - path: apps/*/.packaged + # - name: Publish apps + # run: yarn nx affected --target=publish --parallel --base=HEAD~ --head=HEAD --verbose + # env: + # ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }} + # ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }} + # ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }} + # NODE_ENV: production + # - name: Upload artifacts + # uses: actions/upload-artifact@v3 + # with: + # name: packaged-apps + # path: apps/*/.packaged diff --git a/.prettierrc b/.prettierrc index a8301fa6e..809782b05 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { "trailingComma": "all", - "tabWidth": 4, + "tabWidth": 2, "semi": false, "singleQuote": true } diff --git a/.vscode/settings.json b/.vscode/settings.json index b513b7b4e..8b568feaf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,6 @@ }, "dotnet.defaultSolution": "PlayniteWebPlugin.sln", "typescript.tsdk": ".yarn/sdks/typescript/lib", - "typescript.enablePromptUseWorkspaceTsdk": true -} + "typescript.enablePromptUseWorkspaceTsdk": true, + "prettier.prettierPath": ".yarn/unplugged/prettier-npm-3.1.1-072c31ec21/node_modules/prettier" +} \ No newline at end of file diff --git a/.yarn/unplugged/node-gyp-npm-10.0.1-48708ce70b/node_modules/node-gyp/macOS_Catalina_acid_test.sh b/.yarn/unplugged/node-gyp-npm-10.0.1-48708ce70b/node_modules/node-gyp/macOS_Catalina_acid_test.sh old mode 100644 new mode 100755 diff --git a/apps/PlayniteWebPlugin/project.json b/apps/PlayniteWebPlugin/project.json index a1e6cdd36..7c73d89b7 100644 --- a/apps/PlayniteWebPlugin/project.json +++ b/apps/PlayniteWebPlugin/project.json @@ -28,10 +28,8 @@ "package": { "executor": "nx:run-commands", "options": { - "commands": [ - "Toolbox.exe pack ../../../../../apps/playnite-web-extension/.dist/bin/Release/ ../../../../../apps/playnite-web-extension/.packaged" - ], - "cwd": "libs/build-utils/playnite-toolbox/src/Toolbox" + "commands": "./scripts/package.sh", + "cwd": "{projectRoot}" } }, "test/unit/restore": { diff --git a/apps/PlayniteWebPlugin/scripts/package.sh b/apps/PlayniteWebPlugin/scripts/package.sh new file mode 100755 index 000000000..44559e821 --- /dev/null +++ b/apps/PlayniteWebPlugin/scripts/package.sh @@ -0,0 +1,7 @@ +OS=$(uname) + +if [ ! "$OS" = "WindowsNT" ]; then + exit 0 +fi + +../../../../../libs/build-utils/playnite-toolbox/src/Toolbox/Toolbox.exe pack apps/playnite-web-extension/.dist/bin/Release/ apps/playnite-web-extension/.packaged diff --git a/apps/game-db-updater/Dockerfile b/apps/game-db-updater/Dockerfile new file mode 100644 index 000000000..017f253db --- /dev/null +++ b/apps/game-db-updater/Dockerfile @@ -0,0 +1,6 @@ +FROM node:20-alpine3.19 + +WORKDIR /opt/playnite-web-game-db-updater +COPY .dist/ . + +ENTRYPOINT [ "node index.js" ] diff --git a/apps/game-db-updater/jest.config.js b/apps/game-db-updater/jest.config.js index b6157798f..e3cc8bf75 100644 --- a/apps/game-db-updater/jest.config.js +++ b/apps/game-db-updater/jest.config.js @@ -1,18 +1,18 @@ const { defaults } = require('jest-config') const defaultConfig = { - transform: { - '^.+\\.(j|t)sx?$': ['ts-jest', {}], - }, - resetMocks: true, - modulePathIgnorePatterns: ['/\\.dist/'], - passWithNoTests: false, - coverageDirectory: '/.test-runs/unit', - collectCoverage: true, - moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], - collectCoverageFrom: ['**/src/**', '**/scripts/**'], - coveragePathIgnorePatterns: ['/__tests__/', '/__mocks__/'], - setupFiles: ['/apps/game-db-updater/.tests/setupFiles.ts'], + transform: { + '^.+\\.(j|t)sx?$': ['ts-jest', {}], + }, + resetMocks: true, + modulePathIgnorePatterns: ['/\\.dist/'], + passWithNoTests: false, + coverageDirectory: '/.test-runs/unit', + collectCoverage: true, + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], + collectCoverageFrom: ['**/src/**', '**/scripts/**'], + coveragePathIgnorePatterns: ['/__tests__/', '/__mocks__/'], + setupFiles: ['/.tests/setupFiles.ts'], } module.exports = defaultConfig diff --git a/apps/game-db-updater/project.json b/apps/game-db-updater/project.json index d06b03230..053385cdf 100644 --- a/apps/game-db-updater/project.json +++ b/apps/game-db-updater/project.json @@ -1,31 +1,56 @@ { - "name": "game-db-updater", - "sourceRoot": "apps/game-db-updater/src", - "projectType": "application", - "targets": { - "clean": { - "executor": "nx:run-commands", - "options": { - "command": "yarn rimraf .dist .packaged .test-runs", - "cwd": "{projectRoot}" - } - }, - "start": { - "executor": "nx:run-commands", - "options": { - "cwd": "{projectRoot}", - "command": "DEBUG=game-db-updater/* yarn nodemon --inspect src/index.ts" - } - }, - "test": { - "executor": "nx:run-commands", - "outputs": ["{projectRoot}/.test-runs/unit"], - "options": { - "command": "yarn jest --config jest.config.js", - "cwd": "{projectRoot}" - } - } + "name": "game-db-updater", + "sourceRoot": "apps/game-db-updater/src", + "projectType": "application", + "targets": { + "build": { + "executor": "nx:run-commands", + "outputs": ["{projectRoot}/.dist"], + "options": { + "command": ".yarn/unplugged/@esbuild-linux-x64-npm-0.17.19-08a7136aa6/node_modules/@esbuild/linux-x64/bin/esbuild apps/game-db-updater/src/index.ts --bundle --platform=node --target=node20 --outdir=apps/game-db-updater/.dist" + } }, - "tags": ["linux"], - "implicitDependencies": [] + "clean": { + "executor": "nx:run-commands", + "options": { + "command": "yarn rimraf .dist .packaged .test-runs", + "cwd": "{projectRoot}" + } + }, + "package": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "echo \"Building for $TAG\"", + "docker build --tag $TAG --file Dockerfile .", + "cp -R .dist/ .packaged/" + ], + "cwd": "{projectRoot}" + } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "commands": ["docker push $TAG"], + "cwd": "{projectRoot}" + } + }, + "start": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "command": "DEBUG=game-db-updater/* yarn nodemon --inspect src/index.ts" + } + }, + "test/e2e": { + "executor": "nx:run-commands", + "outputs": ["{projectRoot}/.test-runs/unit"], + "options": { + "command": "yarn jest --config jest.config.js", + "cwd": "{projectRoot}" + } + } + }, + "tags": ["linux"], + "implicitDependencies": [] } diff --git a/apps/game-db-updater/scripts/package.sh b/apps/game-db-updater/scripts/package.sh new file mode 100755 index 000000000..f3c588d88 --- /dev/null +++ b/apps/game-db-updater/scripts/package.sh @@ -0,0 +1,8 @@ +OS=$(uname) + +if [ ! "$OS" = "Linux" ]; then + exit 0 +fi + +docker build --tag "$TAG" --file Dockerfile . +cp -R .dist/ .packaged/ diff --git a/apps/game-db-updater/scripts/publish.sh b/apps/game-db-updater/scripts/publish.sh new file mode 100755 index 000000000..bc2d0525e --- /dev/null +++ b/apps/game-db-updater/scripts/publish.sh @@ -0,0 +1,7 @@ +OS=$(uname) + +if [ ! "$OS" = "Linux" ]; then + exit 0 +fi + +docker push "$TAG" diff --git a/package.json b/package.json index b17ae6ba4..4759999e4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "private": true, "engines": { "node": ">=20.9.0", - "yarn": ">=4.0.0" + "yarn": "^4.0.0" }, "workspaces": [ "apps/*",