Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): adds release process to circleci #808

Merged
merged 37 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
094e007
chore(ci): adds release process to circleci
EverlastingBugstopper Sep 14, 2021
5e4aed4
wip: add missing packages and restructure
EverlastingBugstopper Sep 14, 2021
57fb7a7
wip: persist release binary
EverlastingBugstopper Sep 14, 2021
4df4219
wip: try different env var interpolation strat
EverlastingBugstopper Sep 15, 2021
29e705f
wip: skip tests
EverlastingBugstopper Sep 15, 2021
d999567
wip: add --rebuild to xtask package
EverlastingBugstopper Sep 15, 2021
9a531a9
wip: override macos args with environment variables
EverlastingBugstopper Sep 15, 2021
94b47a4
wip: gitignore artifacts
EverlastingBugstopper Sep 15, 2021
10977aa
fixup node image
EverlastingBugstopper Sep 16, 2021
8250128
fixup artifact names
EverlastingBugstopper Sep 16, 2021
2c19e31
fixup macos artifact name
EverlastingBugstopper Sep 16, 2021
6077f3f
adds notes to gh release
EverlastingBugstopper Sep 16, 2021
4d28760
wip: cleanup gh release
EverlastingBugstopper Sep 16, 2021
95d0dde
wip: test newlines gh release
EverlastingBugstopper Sep 17, 2021
e3d5524
wip: skip builds
EverlastingBugstopper Sep 17, 2021
8418cf1
fixup requires
EverlastingBugstopper Sep 17, 2021
0464b97
move schema copying to xtask
EverlastingBugstopper Sep 17, 2021
76bb348
target specific revision
EverlastingBugstopper Sep 17, 2021
7b5658b
fix newlines
EverlastingBugstopper Sep 17, 2021
9b6732a
again fix newlines
EverlastingBugstopper Sep 17, 2021
048d51a
paramaretize gh release
EverlastingBugstopper Sep 17, 2021
8947b40
srelease/release create
EverlastingBugstopper Sep 17, 2021
65b3ecc
fix indendation
EverlastingBugstopper Sep 17, 2021
da076b9
fake artifacts
EverlastingBugstopper Sep 17, 2021
718cc57
put something in artifacts
EverlastingBugstopper Sep 17, 2021
a52f9d1
dont put options in parameters
EverlastingBugstopper Sep 17, 2021
3145d0c
indent so yaml treats as new lines
EverlastingBugstopper Sep 17, 2021
fae1c05
add back release tag param
EverlastingBugstopper Sep 17, 2021
c8df6bf
convert to yaml block scalar literal style
EverlastingBugstopper Sep 17, 2021
20b2108
actually run the whole pipeline
EverlastingBugstopper Sep 17, 2021
0d7b030
actually actually run the whole pipeline
EverlastingBugstopper Sep 17, 2021
0c7825c
only persist one schema to artifacts
EverlastingBugstopper Sep 17, 2021
2800667
adds npm publish
EverlastingBugstopper Sep 17, 2021
1758f8b
wip tests
EverlastingBugstopper Sep 17, 2021
81086f6
actually run npm publish dry run
EverlastingBugstopper Sep 17, 2021
fd389ab
only run on release tags
EverlastingBugstopper Sep 17, 2021
675d0de
one last copy edit to release checklist
EverlastingBugstopper Sep 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
277 changes: 247 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,110 @@ orbs:
gh: circleci/[email protected]
node: circleci/[email protected]

# These filters are used in all of the jobs for our release workflow
run_release: &run_release
filters:
branches:
ignore: /.*/
tags:
only : /v.*/

# You can uncomment the following alias, and comment the above alias when testing,
# just make sure to update the branch name to the one you're testing on so they run.
# You can bypass the tests if you don't update those steps.
#
# run_release: &run_release
# filters:
# branches:
# only: /avery/test-release-process/
# tags:
# ignore: /.*/

tag_matches_prerelease: &tag_matches_prerelease
matches:
pattern: "^.*(beta|alpha|rc|prerelease|draft|test).*$"
value: << parameters.release_tag >>

should_copy_schema_to_artifacts: &should_copy_schema_to_artifacts
condition:
and:
- equal: [ 'centos', << parameters.platform >> ]
- equal: [ 'package', << parameters.command >> ]

# The main workflows executed for Rover
workflows:
lint:
jobs:
- xtask:
name: Lint (<< matrix.rust_channel >> rust on << matrix.platform >>)
name: Lint
matrix:
parameters:
platform: [ubuntu]
rust_channel: [stable]
command: [lint]
pre-steps:
- node/install:
node-version: "14.17.1"
npm-version: "7.21.1"
test:
jobs:
- xtask:
name: Cargo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
name: Run cargo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [centos, musl, macos, windows]
rust_channel: [stable]
command: [unit-test]

- xtask:
name: Run supergraph-demo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [ubuntu]
rust_channel: [stable]
command: [integration-test]
release:
jobs:
- xtask:
name: Run cargo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [centos, musl, macos, windows]
rust_channel: [stable]
command: [unit-test]
<<: *run_release

- xtask:
name: Cargo tests and supergraph demo (<< matrix.rust_channel >> rust on << matrix.platform >>)
name: Run supergraph-demo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [ubuntu]
rust_channel: [stable]
command: [test]
command: [integration-test]
<<: *run_release

- xtask:
name: Build and bundle release artifacts (<< matrix.platform >>)
matrix:
parameters:
platform: [centos, musl, macos, windows]
rust_channel: [stable]
command: [package]
options: ["--verbose --rebuild"]
requires:
- "Run cargo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)"
- "Run supergraph-demo tests (stable rust on ubuntu)"
<<: *run_release

- publish_release:
name: Publish GitHub release and release to npm
requires:
- "Build and bundle release artifacts (centos)"
- "Build and bundle release artifacts (musl)"
- "Build and bundle release artifacts (macos)"
- "Build and bundle release artifacts (windows)"
<<: *run_release


jobs:
xtask:
Expand All @@ -46,16 +122,43 @@ jobs:
type: executor
command:
type: enum
enum: ["lint", "unit-test", "integration-test", "test", "dist"]
enum: [lint, unit-test, integration-test, test, package]
options:
type: string
default: "--verbose"
executor: << parameters.platform >>
steps:
- checkout
- install_system_deps:
platform: << parameters.platform >>
rust_channel: << parameters.rust_channel >>
- exec_xtask:
platform: << parameters.platform >>
command: << parameters.command >>
- when:
<<: *should_copy_schema_to_artifacts
steps:
- exec_xtask:
platform: << parameters.platform >>
command: << parameters.command >>
options: << parameters.options >> --copy-schema
- unless:
<<: *should_copy_schema_to_artifacts
steps:
- exec_xtask:
platform: << parameters.platform >>
command: << parameters.command >>
options: << parameters.options >>

publish_release:
docker:
- image: cimg/node:lts
resource_class: small
steps:
- checkout
- attach_workspace:
at: artifacts
- gh/setup
- compute_checksums
- gh_release
- npm_publish

# The machines we use to run our workflows on
executors:
Expand All @@ -80,6 +183,9 @@ executors:
resource_class: medium
environment:
XTASK_TARGET: "x86_64-apple-darwin"
APPLE_TEAM_ID: "YQK948L752"
APPLE_USERNAME: "[email protected]"
MACOS_PRIMARY_BUNDLE_ID: com.apollographql.rover

windows: &windows_executor
machine:
Expand Down Expand Up @@ -147,24 +253,21 @@ commands:
- run:
name: Install musl-tools
command: sudo apt-get install -y musl-tools
- when:
condition:
or:
- equal: [ *ubuntu_executor, << parameters.platform >> ]
steps:
- node/install:
node-version: "14.17.1"
npm-version: "7.21.1"

- when:
condition:
equal: [ *macos_executor, << parameters.platform >> ]
steps:
- run:
name: Skip homebrew update
command: echo "HOMEBREW_NO_AUTO_UPDATE=1" >> $BASH_ENV
- run:
name: Install [email protected]
command: brew install [email protected]
- run:
name: Install p7zip
command: brew install p7zip

- install_rust_toolchain:
rust_channel: << parameters.rust_channel >>
platform: << parameters.platform >>
Expand Down Expand Up @@ -215,31 +318,145 @@ commands:
parameters:
command:
type: enum
enum: [lint, integration-test, unit-test, "test", "dist"]
enum: [lint, integration-test, unit-test, test, package]
options:
type: string
default: --verbose
platform:
type: executor
steps:
- restore_cache:
keys:
- rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }}

- run:
command: cargo xtask << parameters.command >> << parameters.options >>

- save_cache:
key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }}
paths:
- target/

- when:
condition:
equal: [ package, << parameters.command >> ]
steps:
- persist_to_workspace:
root: artifacts
paths:
- "*"
gh_release:
steps:
- unless:
condition: << pipeline.git.tag >>
steps:
- run:
command: >
mkdir -p artifacts && cd artifacts && echo "this release is part of a test, please ignore." >> this_is_a_fake_release.txt
- exec_gh_release:
release_tag: << pipeline.git.branch >>
extra_options: "--draft"
- when:
condition: << pipeline.git.tag >>
steps:
- exec_gh_release

exec_gh_release:
parameters:
release_tag:
type: string
default: << pipeline.git.tag >>
extra_options:
type: string
default: ""
steps:
- when:
condition:
<<: *tag_matches_prerelease
steps:
- run:
name: Create draft GitHub prerelease
command: |
gh release create << parameters.release_tag >> \
--prerelease \
--title << parameters.release_tag >> \
<< parameters.extra_options >> \
--notes '<!-- changelog -->
---
This release was automatically created by [CircleCI](./.circleci/config.yml).

If you would like to verify that the binary you have downloaded was built from the source code in this repository, you can compute a checksum of the zipped tarball and compare it to the checksums that are included as release artifacts.

Binaries built for MacOS are signed, notarized, and automatically verified with [Gatekeeper](https://support.apple.com/guide/deployment-reference-macos/using-gatekeeper-apd02b925e38/web).' \
artifacts/*
- unless:
condition:
<<: *tag_matches_prerelease
steps:
- run:
name: Create draft GitHub release
command: |
gh release create << parameters.release_tag >> \
--title << parameters.release_tag >> \
<< parameters.extra_options >> \
--notes '<!-- changelog -->
---
This release was automatically created by [CircleCI](./.circleci/config.yml).

If you would like to verify that the binary you have downloaded was built from the source code in this repository, you can compute a checksum of the zipped tarball and compare it to the checksums that are included as release artifacts.

Binaries built for MacOS are signed, notarized, and automatically verified with [Gatekeeper](https://support.apple.com/guide/deployment-reference-macos/using-gatekeeper-apd02b925e38/web).' \
artifacts/*
compute_checksums:
steps:
- run:
name: Compute SHA256 checksums
command: >
cd artifacts && sha256sum *.tar.gz > sha256sums.txt
- run:
name: Compute md5 checksums
command: >
cd artifacts && md5sum *.tar.gz > md5sums.txt
- run:
name: Compute SHA1 checksums
command: >
cd artifacts && sha1sum *.tar.gz > sha1sums.txt
npm_publish:
steps:
- unless:
condition: << pipeline.git.tag >>
steps:
- exec_npm_publish:
options: "--dry-run"
release_tag: << pipeline.git.branch >>
- when:
condition: << pipeline.git.tag >>
steps:
- exec_npm_publish

exec_npm_publish:
parameters:
options:
type: string
default: ""
npm_dir:
type: string
default: "./installers/npm"
release_tag:
type: string
default: << pipeline.git.tag >>
steps:
- unless:
condition:
# cargo xtask lint is the only xtask command that doesn't take a target
equal: [ lint, << parameters.command >> ]
<<: *tag_matches_prerelease
steps:
- run:
name: cargo xtask << parameters.command >>
command: cargo xtask << parameters.command >> --verbose
name: Publish to npm (stable)
command: cd << parameters.npm_dir >> && npm publish << parameters.options >>
- when:
condition:
not:
equal: [ lint, << parameters.command >> ]
<<: *tag_matches_prerelease
steps:
- run:
name: cargo xtask << parameters.command >>
command: cargo xtask << parameters.command >> --target $XTASK_TARGET --verbose
- save_cache:
key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }}
paths:
- target/

name: Publish to npm (beta)
command: cd << parameters.npm_dir >> && npm publish --tag beta << parameters.options >>
Loading