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: add yarn berry to ci check #1865

Merged
merged 34 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
eb65dd4
chore: add yarn berry to ci check
sweatybridge Jan 20, 2024
c042c78
fix: update bin link path for yarn berry
sweatybridge Jan 20, 2024
85fe697
Update postinstall.js
sweatybridge Jan 20, 2024
69ceef7
Update postinstall.js
sweatybridge Jan 20, 2024
80c1056
Update postinstall.js
sweatybridge Jan 20, 2024
6851548
Update install.yml
sweatybridge Jan 20, 2024
6c3f670
Update install.yml
sweatybridge Jan 20, 2024
b211a5d
Update install.yml
sweatybridge Jan 20, 2024
cd2489a
Update install.yml
sweatybridge Jan 20, 2024
f9391ae
Update install.yml
sweatybridge Jan 20, 2024
cddee6a
Update postinstall.js
sweatybridge Jan 20, 2024
fbd9b92
Update install.yml
sweatybridge Jan 20, 2024
f078d0f
Update install.yml
sweatybridge Jan 20, 2024
df61dad
Update install.yml
sweatybridge Jan 20, 2024
e7d020d
Update install.yml
sweatybridge Jan 20, 2024
3b60228
Update install.yml
sweatybridge Jan 20, 2024
6824320
chore: print out binary path
sweatybridge Jan 20, 2024
962d7c4
chore: ls bin dir
sweatybridge Jan 20, 2024
4fcf991
chore: debug command
sweatybridge Jan 20, 2024
b64273f
chore: copy symlink
sweatybridge Jan 20, 2024
d7df10e
chore: update package json for windows
sweatybridge Jan 20, 2024
d52125d
chore: print updated json
sweatybridge Jan 20, 2024
5bcbc6b
chore: use exec
sweatybridge Jan 20, 2024
3f1cdc3
chore: use top level flag
sweatybridge Jan 20, 2024
c32351c
chore: use path to bin
sweatybridge Jan 20, 2024
2add64a
chore: test more
sweatybridge Jan 21, 2024
0512569
chore: test copy link
sweatybridge Jan 21, 2024
64159a0
Update postinstall.js
sweatybridge Jan 21, 2024
53ef3fe
Update postinstall.js
sweatybridge Jan 21, 2024
3a32308
Update install.yml
sweatybridge Jan 21, 2024
ded8f8f
Update install.yml
sweatybridge Jan 21, 2024
cf181f5
Update install.yml
sweatybridge Jan 21, 2024
10c4197
chore: ci patches
sweatybridge Jan 25, 2024
b83e4a6
chore: cleanup
sweatybridge Jan 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
25 changes: 23 additions & 2 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,33 @@ jobs:
with:
name: installer

# Berry fails to find executable on windows
# - run: yarn set version berry
- run: yarn init -y
- run: yarn add -D ./supabase-1.28.0.tgz
- run: yarn supabase --version

yarn_berry:
needs: pack
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/download-artifact@v4
with:
name: installer

- run: yarn set version berry
# - run: yarn config set nodeLinker node-modules
- run: yarn init -y
- run: yarn add -D ./supabase-1.28.0.tgz
- if: ${{ matrix.os != 'windows-latest' }}
run: yarn supabase --version
# Workaround for running extensionless executable on windows
- if: ${{ matrix.os == 'windows-latest' }}
run: |
& "$(yarn bin supabase).exe" --version

pnpm:
needs: pack
strategy:
Expand Down
40 changes: 15 additions & 25 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,21 @@ const PLATFORM_MAPPING = {
};

const arch = ARCH_MAPPING[process.arch];

const platform = PLATFORM_MAPPING[process.platform];

// TODO: import pkg from "../package.json" assert { type: "json" };
const readPackageJson = async () => {
const packageJsonPath = path.join(".", "package.json");
const contents = await fs.promises.readFile(packageJsonPath);
const contents = await fs.promises.readFile("package.json");
return JSON.parse(contents);
};

const parsePackageJson = (packageJson) => {
if (!arch) {
throw Error(
"Installation is not supported for this architecture: " + process.arch
);
}

if (!platform) {
throw Error(
"Installation is not supported for this platform: " + process.platform
);
}

// Build the download url from package.json
// Build the download url from package.json
const getDownloadUrl = (packageJson) => {
const pkgName = packageJson.name;
const version = packageJson.version;
const repo = packageJson.repository;
const url = `https://github.com/${repo}/releases/download/v${version}/${pkgName}_${platform}_${arch}.tar.gz`;

let binPath = path.join("bin", "supabase");
if (platform == "windows") {
binPath += ".exe";
}

return { binPath, url };
return url;
};

const fetchAndParseCheckSumFile = async (packageJson, agent) => {
Expand Down Expand Up @@ -98,6 +78,7 @@ const errGlobal = `Installing Supabase CLI as a global module is not supported.
Please use one of the supported package managers: https://github.com/supabase/cli#install-the-cli
`;
const errChecksum = "Checksum mismatch. Downloaded data might be corrupted.";
const errUnsupported = `Installation is not supported for ${process.platform} ${process.arch}`;

/**
* Reads the configuration from application's package.json,
Expand All @@ -113,9 +94,17 @@ async function main() {
if (process.env.npm_config_global || yarnGlobal) {
throw errGlobal;
}
if (!arch || !platform) {
throw errUnsupported;
}

const pkg = await readPackageJson();
const { binPath, url } = parsePackageJson(pkg);
if (platform === "windows") {
// Update bin path in package.json
pkg.bin[pkg.name] += ".exe";
}

const binPath = pkg.bin[pkg.name];
const binDir = path.dirname(binPath);
await fs.promises.mkdir(binDir, { recursive: true });

Expand All @@ -124,6 +113,7 @@ async function main() {
const binName = path.basename(binPath);
const untar = tar.x({ cwd: binDir }, [binName]);

const url = getDownloadUrl(pkg);
console.info("Downloading", url);
const proxyUrl =
process.env.npm_config_https_proxy ||
Expand Down