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

CLI: Allow binaries to autoupdate #1540

Merged
merged 58 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e09d71d
autoupdate oclif
eemmiillyy Jul 15, 2024
94b2df7
clean
eemmiillyy Jul 15, 2024
434fa5f
use arn
eemmiillyy Jul 16, 2024
6cb6f7b
types
eemmiillyy Jul 16, 2024
1427ec2
only run on main
eemmiillyy Jul 16, 2024
25fb9f3
use arn
eemmiillyy Jul 16, 2024
9557679
id-token perm
eemmiillyy Jul 16, 2024
b32c17f
perm
eemmiillyy Jul 16, 2024
240ff75
scoped permission
eemmiillyy Jul 16, 2024
d1d2fab
write
eemmiillyy Jul 16, 2024
09fd500
var
eemmiillyy Jul 16, 2024
e14cbf2
chdir
eemmiillyy Jul 16, 2024
c6d297c
wait
eemmiillyy Jul 16, 2024
3a31d21
use targets
eemmiillyy Jul 16, 2024
7309fbe
continue
eemmiillyy Jul 16, 2024
6569c47
add dep
eemmiillyy Jul 16, 2024
ca79754
wrong param
eemmiillyy Jul 16, 2024
5702df0
acl
eemmiillyy Jul 16, 2024
6838709
fix file name
eemmiillyy Jul 17, 2024
619f4a0
target
eemmiillyy Jul 17, 2024
72b406c
test
eemmiillyy Jul 17, 2024
12c616b
fix
eemmiillyy Jul 17, 2024
dc90ebe
upload fix
eemmiillyy Jul 17, 2024
326db88
pkg
eemmiillyy Jul 17, 2024
44aa875
fix
eemmiillyy Jul 17, 2024
f09fbc0
promote
eemmiillyy Jul 17, 2024
d5b4655
test release gh
eemmiillyy Jul 17, 2024
e06d26a
host
eemmiillyy Jul 17, 2024
6c4b528
extra slash
eemmiillyy Jul 17, 2024
a696988
workflow
eemmiillyy Jul 17, 2024
aabe943
deb
eemmiillyy Jul 17, 2024
1773895
deb
eemmiillyy Jul 17, 2024
a73dfb7
deb
eemmiillyy Jul 17, 2024
e033dda
deb
eemmiillyy Jul 17, 2024
e2eb1d6
test
eemmiillyy Jul 18, 2024
ba9a21b
test
eemmiillyy Jul 18, 2024
df74102
test
eemmiillyy Jul 18, 2024
091b329
separate steps
eemmiillyy Jul 18, 2024
04b8a16
chdir
eemmiillyy Jul 18, 2024
b314368
run from dist folder
eemmiillyy Jul 18, 2024
9294f43
skip windows tmp
eemmiillyy Jul 18, 2024
61aa2d0
list files
eemmiillyy Jul 18, 2024
cf35914
cwd
eemmiillyy Jul 18, 2024
af77ad1
log error
eemmiillyy Jul 18, 2024
c60c242
test
eemmiillyy Jul 18, 2024
f7352bd
test
eemmiillyy Jul 18, 2024
eee5a5d
test
eemmiillyy Jul 18, 2024
da2760f
test
eemmiillyy Jul 18, 2024
73d572e
windows
eemmiillyy Jul 18, 2024
c6b84d6
test gh
eemmiillyy Jul 19, 2024
629599f
win path
eemmiillyy Jul 19, 2024
9946471
clean
eemmiillyy Jul 19, 2024
38440db
clean
eemmiillyy Jul 19, 2024
fa4cda3
pr changes
eemmiillyy Jul 19, 2024
2e538c7
Merge branch 'main' into feat/cli-autoupdates
eemmiillyy Jul 23, 2024
7224612
Create thick-bags-grab.md
SferaDev Jul 25, 2024
12884e2
feat: setup autoupdates for homebrew formula (#1543)
eemmiillyy Jul 25, 2024
9b2b2e9
node version
eemmiillyy Jul 25, 2024
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
78 changes: 76 additions & 2 deletions .github/workflows/release-cli-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,28 @@ on:
description: 'Published packages'
required: true
type: string
commitSha:
description: 'Commit SHA'
required: true
type: string
workflow_dispatch:
inputs:
publishedPackages:
description: 'Published packages'
required: true
default: '[{"name": "@xata.io/cli", "version": "1.2.0"}]'
type: string
commitSha:
description: 'Commit SHA'
required: true
type: string

permissions:
id-token: write
contents: write
packages: write
pages: write
pull-requests: write

jobs:
release-cli-assets:
Expand Down Expand Up @@ -81,12 +96,71 @@ jobs:
sudo apt-get install -y nsis
sudo apt-get install -y p7zip

- name: Release CLI Assets
run: pnpm run release:cli
- name: Configure AWS Credentials for production
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CLI_ASSETS_UPLOAD_ROLE }}
aws-region: us-east-1
mask-aws-account-id: 'no'

- name: Pack
run: pnpm run release:cli:pack
env:
PUBLISHED_PACKAGES: ${{ inputs.publishedPackages }}
MATRIX_OS: ${{ matrix.os }}

- name: Upload CLI Assets to GitHub Releases
run: pnpm run release:cli:upload:gh
env:
MATRIX_OS: ${{ matrix.os }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Debian cert
if: matrix.os == 'ubuntu-latest'
working-directory: /home/runner/work/client-ts/client-ts/cli/dist/deb
run: |
echo "$DEBIAN_GPG_KEY_PRIVATE" | gpg --import --batch --passphrase "$DEBIAN_GPG_KEY_PASS"
gpg --digest-algo SHA512 --clearsign --pinentry-mode loopback --passphrase "$DEBIAN_GPG_KEY_PASS" -u $DEBIAN_GPG_KEY_ID -o InRelease Release
gpg --digest-algo SHA512 -abs --pinentry-mode loopback --passphrase "$DEBIAN_GPG_KEY_PASS" -u $DEBIAN_GPG_KEY_ID -o Release.gpg Release
echo "Signed debian packages successfully"
echo "sha256 sums:"
sha256sum *Release*

mkdir -p /home/runner/work/client-ts/client-ts/cli/dist/apt
echo "$DEBIAN_GPG_KEY_PUBLIC" > /home/runner/work/client-ts/client-ts/cli/dist/apt/release.key
env:
DEBIAN_GPG_KEY_PRIVATE: ${{ secrets.DEBIAN_GPG_KEY_PRIVATE }}
DEBIAN_GPG_KEY_PASS: ${{ secrets.DEBIAN_GPG_KEY_PASS }}
DEBIAN_GPG_KEY_PUBLIC: ${{ secrets.DEBIAN_GPG_KEY_PUBLIC }}
DEBIAN_GPG_KEY_ID: ${{ secrets.DEBIAN_GPG_KEY_ID }}

- name: Upload and Promote CLI Assets to S3
run: pnpm run release:cli:upload:s3
env:
MATRIX_OS: ${{ matrix.os }}
COMMIT_SHA: ${{ inputs.commitSha }}

- name: Pack (Windows only)
if: matrix.os == 'ubuntu-latest'
run: pnpm run release:cli:pack
env:
PUBLISHED_PACKAGES: ${{ inputs.publishedPackages }}
MATRIX_OS: ${{ matrix.os }}
OS_OVERRIDE: windows-latest
- name: Upload CLI Assets to GitHub Releases (Windows only)
run: pnpm run release:cli:upload:gh
if: matrix.os == 'ubuntu-latest'
env:
MATRIX_OS: ${{ matrix.os }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS_OVERRIDE: windows-latest
- name: Upload and Promote CLI Assets to S3 (Windows only)
if: matrix.os == 'ubuntu-latest'
run: pnpm run release:cli:upload:s3
env:
MATRIX_OS: ${{ matrix.os }}
COMMIT_SHA: ${{ inputs.commitSha }}
OS_OVERRIDE: windows-latest

- name: Clean up keychain
if: matrix.os == 'macos-latest'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ jobs:
publish-cli-assets:
name: Publish CLI assets
needs: [release]
if: needs.release.outputs.published == 'true'
if: needs.release.outputs.published == 'true' && github.ref_name == 'main'
uses: ./.github/workflows/release-cli-assets.yml
with:
publishedPackages: ${{ needs.release.outputs.publishedPackages }}
commitSha: ${{ github.sha }}
secrets: inherit
17 changes: 14 additions & 3 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"engines": {
"node": ">=8"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need this, also the version looks odd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need it because oclif throws an error if it is undefined: https://github.com/oclif/oclif/blob/main/src/tarballs/build.ts#L258

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version should it be instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

18 probably

"dependencies": {
"@oclif/core": "^4.0.8",
"@oclif/plugin-help": "^6.2.5",
"@oclif/plugin-not-found": "^3.2.10",
"@oclif/plugin-plugins": "^5.3.4",
"@oclif/plugin-update": "^4.4.9",
"@types/ini": "^4.1.1",
"@types/prompts": "^2.4.9",
"@types/semver": "^7.5.8",
Expand All @@ -40,18 +44,18 @@
"enquirer": "^2.4.1",
"env-editor": "^1.1.0",
"ini": "^4.1.3",
"lodash.keyby": "^4.6.0",
"lodash.compact": "^3.0.1",
"lodash.get": "^4.4.2",
"lodash.keyby": "^4.6.0",
"lodash.set": "^4.3.2",
"node-fetch": "^3.3.2",
"open": "^10.1.0",
"prompts": "^2.4.2",
"relaxed-json": "^1.0.3",
"semver": "^7.6.2",
"text-table": "^0.2.0",
"tslib": "^2.6.3",
"tmp": "^0.2.3",
"tslib": "^2.6.3",
"type-fest": "^4.21.0",
"which": "^4.0.0",
"zod": "^3.23.8"
Expand All @@ -77,6 +81,12 @@
},
"oclif": {
"bin": "xata",
"update": {
"s3": {
"host": "https://xata-cli-assets.s3.us-east-1.amazonaws.com",
"bucket": "xata-cli-assets"
}
},
"hooks": {
"init": "./dist/hooks/init/compatibility"
},
Expand All @@ -95,7 +105,8 @@
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-plugins",
"@oclif/plugin-not-found"
"@oclif/plugin-not-found",
"@oclif/plugin-update"
],
"topicSeparator": " ",
"topics": {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"scripts": {
"test": "vitest",
"test:canary": "tsx ./scripts/test-canary.ts",
"release:cli": "tsx ./scripts/release-cli.ts",
"release:cli:pack": "tsx ./scripts/release-cli-pack.ts",
"release:cli:upload:gh": "tsx ./scripts/release-cli-upload-gh.ts",
"release:cli:upload:s3": "tsx ./scripts/release-cli-upload-s3.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepare": "husky install",
Expand Down
Loading
Loading