console/.github/workflows/release-alpha.yaml

206 lines
6.8 KiB
YAML

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
permissions:
pull-requests: write
actions: write
contents: write
with:
npmTag: alpha
buildScript: build:libraries
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
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
- name: pack tarballs
working-directory: packages/libraries/cli
run: pnpm oclif:pack
- name: upload darwin arm64
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
with:
name: hive-cli-darwin-arm64
path: ./packages/libraries/cli/dist/*-darwin-arm64.tar.gz
- name: upload darwin x64
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
with:
name: hive-cli-darwin-x64
path: ./packages/libraries/cli/dist/*-darwin-x64.tar.gz
- name: upload win x64
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
with:
name: hive-cli-win-x64
path: ./packages/libraries/cli/dist/*-win32-x64.tar.gz
- name: upload win x86
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
with:
name: hive-cli-win-x86
path: ./packages/libraries/cli/dist/*-win32-x86.tar.gz
- name: upload linux arm
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
with:
name: hive-cli-linux-arm
path: ./packages/libraries/cli/dist/*-linux-arm.tar.gz
- name: upload linux x64
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
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@cc203385981b70ca67e1cc392babf9cc229d5806 # v4
with:
name: hive-cli-darwin-x64
- name: Pull artifact for ubuntu
if: matrix.os == 'ubuntu-latest'
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4
with:
name: hive-cli-linux-x64
- name: Unzip and run
run: |
rm -rf /usr/local/bin/node
rm -rf /usr/local/lib/node
rm -rf /opt/homebrew/bin/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
extract-cli-version:
needs: [npm]
runs-on: ubuntu-22.04
name: Extract CLI version
outputs:
published: ${{ steps.cli.outputs.published }}
version: ${{ steps.cli.outputs.version }}
steps:
- name: Extract published version
if:
needs.npm.outputs.published && contains(needs.npm.outputs.publishedPackages,
'"@graphql-hive/cli"')
id: cli
run: |
echo '${{needs.npm.outputs.publishedPackages}}' > cli-ver.json
VERSION=`echo $(jq -r '.[] | select(.name | endswith("@graphql-hive/cli")).version' cli-ver.json)`
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "published=true" >> "$GITHUB_OUTPUT"
publish_docker:
needs: [extract-cli-version]
uses: ./.github/workflows/dockerize-cli.yaml
if: ${{ needs.extract-cli-version.outputs.published == 'true' }}
with:
cliVersion: ${{ needs.extract-cli-version.outputs.version }}
publishLatest: false
secrets: inherit
cargo:
needs: [npm]
runs-on: ubuntu-22.04
permissions:
pull-requests: write
actions: write
contents: write
steps:
- name: checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 2
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- name: setup environment
uses: ./.github/actions/setup
with:
codegen: false # no need to run because release script will run it anyway
actor: alpha-rust
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: extract published plugin version
id: plugin-crate
if:
needs.npm.outputs.published && contains(needs.npm.outputs.publishedPackages,
'"hive-apollo-router-plugin"')
run: |
cargo install set-cargo-version
echo '${{needs.npm.outputs.publishedPackages}}' > published.json
VERSION=`echo $(jq -r '.[] | select(.name | endswith("hive-apollo-router-plugin")).version' published.json)`
set-cargo-version ./packages/libraries/router/Cargo.toml $VERSION
- name: extract published sdk version
id: sdk-crate
if:
needs.npm.outputs.published && contains(needs.npm.outputs.publishedPackages,
'"hive-console-sdk-rs"')
run: |
cargo install set-cargo-version
echo '${{needs.npm.outputs.publishedPackages}}' > published.json
VERSION=`echo $(jq -r '.[] | select(.name | endswith("hive-console-sdk-rs")).version' published.json)`
set-cargo-version ./packages/libraries/sdk-rs/Cargo.toml $VERSION
echo "crate_publish=true" >> $GITHUB_OUTPUT
# Find and replace the version of "hive-console-sdk" dependency in router Cargo.toml
if [ -f ./packages/libraries/router/Cargo.toml ]; then
SDK_VERSION_LINE=$(grep -n 'hive-console-sdk' ./packages/libraries/router/Cargo.toml | head -n 1 | cut -d: -f1)
if [ ! -z "$SDK_VERSION_LINE" ]; then
sed -i "${SDK_VERSION_LINE}s/version = \".*\"/version = \"$VERSION\"/" ./packages/libraries/router/Cargo.toml
fi
fi
- name: release to Crates.io
if:
steps.sdk-crate.outputs.crate_publish == 'true' ||
steps.plugin-crate.outputs.crate_publish == 'true'
run: |
cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
cargo publish --allow-dirty --no-verify