diff --git a/.changeset/fast-doors-clean.md b/.changeset/fast-doors-clean.md new file mode 100644 index 00000000000..6aba5959716 --- /dev/null +++ b/.changeset/fast-doors-clean.md @@ -0,0 +1,5 @@ +--- +'@graphql-hive/cli': minor +--- + +Support HIVE_AUTHOR and HIVE_COMMIT env vars diff --git a/.changeset/forty-plants-yawn.md b/.changeset/forty-plants-yawn.md new file mode 100644 index 00000000000..b3255dfe43f --- /dev/null +++ b/.changeset/forty-plants-yawn.md @@ -0,0 +1,5 @@ +--- +'@graphql-hive/cli': patch +--- + +Adds windows installer diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 493b7457e23..7c5290d027d 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -90,16 +90,9 @@ jobs: # Release alpha version on NPM for Hive libraries alpha: - uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main + uses: ./.github/workflows/release-alpha.yaml if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }} - with: - npmTag: alpha - buildScript: build:libraries - nodeVersion: 18 - packageManager: pnpm - secrets: - githubToken: ${{ secrets.GITHUB_TOKEN }} - npmToken: ${{ secrets.NPM_TOKEN }} + secrets: inherit # Release RC version on NPM for Hive libraries release-candidate: diff --git a/.github/workflows/release-alpha.yaml b/.github/workflows/release-alpha.yaml new file mode 100644 index 00000000000..a103b1a8951 --- /dev/null +++ b/.github/workflows/release-alpha.yaml @@ -0,0 +1,119 @@ +on: + workflow_call: + +jobs: + # Release alpha version on NPM for Hive libraries + npm: + uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main + with: + npmTag: alpha + buildScript: build:libraries + nodeVersion: 18 + packageManager: pnpm + secrets: + githubToken: ${{ secrets.GITHUB_TOKEN }} + npmToken: ${{ secrets.NPM_TOKEN }} + + # Upload zipped tarballs to GitHub + cli-artifacts: + runs-on: ubuntu-22.04 + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: setup environment + uses: ./.github/actions/setup + with: + codegen: false # no need to run because release script will run it anyway + actor: release-alpha + + - name: build libraries + run: pnpm build:libraries + + # Needed for `oclif pack win` + - name: Install NSIS + run: | + sudo apt-get -y install nsis + + - name: pack tarballs + working-directory: packages/libraries/cli + run: pnpm oclif:pack + + - name: upload darwin arm64 + uses: actions/upload-artifact@v3 + with: + name: hive-cli-darwin-arm64 + path: ./packages/libraries/cli/dist/*-darwin-arm64.tar.gz + + - name: upload darwin x64 + uses: actions/upload-artifact@v3 + with: + name: hive-cli-darwin-x64 + path: ./packages/libraries/cli/dist/*-darwin-x64.tar.gz + + - name: upload windows x64 + uses: actions/upload-artifact@v3 + with: + name: hive-cli-windows-x64 + path: ./packages/libraries/cli/dist/win32/*-x64.exe + + - name: upload windows x86 + uses: actions/upload-artifact@v3 + with: + name: hive-cli-windows-x86 + path: ./packages/libraries/cli/dist/win32/*-x86.exe + + - name: upload linux arm + uses: actions/upload-artifact@v3 + with: + name: hive-cli-linux-arm + path: ./packages/libraries/cli/dist/*-linux-arm.tar.gz + + - name: upload linux x64 + uses: actions/upload-artifact@v3 + with: + name: hive-cli-linux-x64 + path: ./packages/libraries/cli/dist/*-linux-x64.tar.gz + + cli-test: + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + needs: [cli-artifacts] + steps: + - name: Pull artifact for macos + if: matrix.os == 'macos-latest' + uses: actions/download-artifact@v3 + with: + name: hive-cli-darwin-x64 + + - name: Pull artifact for ubuntu + if: matrix.os == 'ubuntu-latest' + uses: actions/download-artifact@v3 + with: + name: hive-cli-linux-x64 + + - name: Pull artifact for windows + if: matrix.os == 'windows-latest' + uses: actions/download-artifact@v3 + with: + name: hive-cli-windows-x64 + + - name: Unzip and run + run: | + rm -rf /usr/local/bin/node + rm -rf /usr/local/lib/node + + if command -v node &> /dev/null + then + echo "Expected node to not be installed" + command -v node + exit 1 + fi + tar -xzf *.tar.gz + # Expect the command to succeed + ./hive/bin/hive --version || exit 1 diff --git a/.github/workflows/release-stable.yaml b/.github/workflows/release-stable.yaml index 7ea82776ab0..44dcae571ec 100644 --- a/.github/workflows/release-stable.yaml +++ b/.github/workflows/release-stable.yaml @@ -49,6 +49,11 @@ jobs: echo "version=$VERSION" >> $GITHUB_OUTPUT echo "publish=true" >> $GITHUB_OUTPUT + # Needed for `oclif pack win` + - name: Install NSIS + run: | + sudo apt-get -y install nsis + - name: pack tarballs if: steps.cli.outputs.publish == 'true' working-directory: packages/libraries/cli @@ -65,5 +70,5 @@ jobs: env: VERSION: ${{ steps.cli.outputs.version }} run: - pnpm oclif promote --no-xz --sha ${GITHUB_SHA:0:7} --version $VERSION || pnpm oclif - promote --no-xz --sha ${GITHUB_SHA:0:8} --version $VERSION + pnpm oclif promote --no-xz --sha ${GITHUB_SHA:0:7} --version $VERSION --win || pnpm oclif + promote --no-xz --sha ${GITHUB_SHA:0:8} --version $VERSION --win diff --git a/docker/cli.dockerfile b/docker/cli.dockerfile new file mode 100644 index 00000000000..cf04d62a06f --- /dev/null +++ b/docker/cli.dockerfile @@ -0,0 +1,20 @@ +FROM node:18.16.0-slim + +WORKDIR /usr/src/app +COPY . /usr/src/app/ + +RUN npm install --omit=dev +RUN npm install -g file:./ + +LABEL org.opencontainers.image.title=$IMAGE_TITLE +LABEL org.opencontainers.image.version=$RELEASE +LABEL org.opencontainers.image.description=$IMAGE_DESCRIPTION +LABEL org.opencontainers.image.authors="The Guild" +LABEL org.opencontainers.image.vendor="Kamil Kisiela" +LABEL org.opencontainers.image.url="https://github.com/kamilkisiela/graphql-hive" + +ENV ENVIRONMENT production +ENV RELEASE $RELEASE +RUN npx hive --version + +ENTRYPOINT ["npx", "hive"] diff --git a/docker/docker.hcl b/docker/docker.hcl index 26f4139daf8..b8533d7d88d 100644 --- a/docker/docker.hcl +++ b/docker/docker.hcl @@ -76,6 +76,13 @@ target "router-base" { } } +target "cli-base" { + dockerfile = "${PWD}/docker/cli.dockerfile" + args = { + RELEASE = "${RELEASE}" + } +} + target "target-dev" {} target "target-ci" { @@ -343,6 +350,21 @@ target "apollo-router" { ] } +target "cli" { + inherits = ["cli-base", get_target()] + context = "${PWD}/packages/libraries/cli" + args = { + IMAGE_TITLE = "graphql-hive/cli" + IMAGE_DESCRIPTION = "GraphQL Hive CLI" + } + tags = [ + local_image_tag("cli"), + stable_image_tag("cli"), + image_tag("cli", COMMIT_SHA), + image_tag("cli", BRANCH_NAME) + ] +} + group "build" { targets = [ "emails", @@ -358,7 +380,8 @@ group "build" { "server", "stripe-billing", "composition-federation-2", - "app" + "app", + "cli" ] } @@ -384,3 +407,9 @@ group "rust" { "apollo-router" ] } + +group "cli" { + targets = [ + "cli" + ] +} diff --git a/package.json b/package.json index 1930200ad3b..d1427e7707f 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,6 @@ "patchedDependencies": { "@theguild/buddy@0.1.0": "patches/@theguild__buddy@0.1.0.patch", "mjml-core@4.14.0": "patches/mjml-core@4.14.0.patch", - "@oclif/core@1.23.0": "patches/@oclif__core@1.23.0.patch", "oclif@3.9.0": "patches/oclif@3.9.0.patch", "@slonik/migrator@0.11.3": "patches/@slonik__migrator@0.11.3.patch", "@apollo/federation@0.38.1": "patches/@apollo__federation@0.38.1.patch", @@ -120,7 +119,8 @@ "bullmq@3.15.0": "patches/bullmq@3.15.0.patch", "@theguild/editor@1.2.5": "patches/@theguild__editor@1.2.5.patch", "eslint@8.41.0": "patches/eslint@8.41.0.patch", - "@graphql-eslint/eslint-plugin@3.19.1": "patches/@graphql-eslint__eslint-plugin@3.19.1.patch" + "@graphql-eslint/eslint-plugin@3.19.1": "patches/@graphql-eslint__eslint-plugin@3.19.1.patch", + "@oclif/core@2.8.5": "patches/@oclif__core@2.8.5.patch" } } } diff --git a/packages/libraries/cli/.dockerignore b/packages/libraries/cli/.dockerignore new file mode 100644 index 00000000000..3e04c8ca45a --- /dev/null +++ b/packages/libraries/cli/.dockerignore @@ -0,0 +1,2 @@ +node_modules +hive.json \ No newline at end of file diff --git a/packages/libraries/cli/README.md b/packages/libraries/cli/README.md index 124b22cff41..f865acfc0bc 100644 --- a/packages/libraries/cli/README.md +++ b/packages/libraries/cli/README.md @@ -58,18 +58,18 @@ USAGE ] [--cdn.accessToken ] [--outputFile ] FLAGS - --artifact=(sdl|supergraph|metadata|services|sdl.graphql|sdl.graphqls) (required) artifact to fetch (Note: supergraph - is only available for federation projects) - --cdn.accessToken= CDN access token - --cdn.endpoint= CDN endpoint - --outputFile= whether to write to a file instead of stdout + --artifact=