Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
- name: Package extensions
run: pnpm package-extensions
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
SHOULD_PUBLISH: ${{ github.ref_name == 'main' }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
Expand Down
14 changes: 11 additions & 3 deletions src/package-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from "./lib/validation.js";

const {
BRANCH_HEAD_SHA,
S3_ACCESS_KEY,
S3_SECRET_KEY,
S3_BUCKET,
Expand All @@ -48,6 +49,10 @@ ENVIRONMENT VARIABLES
S3_BUCKET Name of the bucket where extensions are published
SHOULD_PUBLISH Whether to publish packages to the blob store.
Set this to "true" to publish the packages.
BRANCH_HEAD_SHA SHA of the branch head commit. This is used to
determine the changed extensions. If this is not
set, the changes will be determined based on the
extensions.toml of the main branch.
`;

let selectedExtensionId;
Expand Down Expand Up @@ -97,7 +102,7 @@ try {

const extensionIds = shouldPublish
? await unpublishedExtensionIds(extensionsToml)
: await changedExtensionIds(extensionsToml);
: await changedExtensionIds(extensionsToml, BRANCH_HEAD_SHA);

for (const extensionId of extensionIds) {
if (selectedExtensionId && extensionId !== selectedExtensionId) {
Expand Down Expand Up @@ -296,11 +301,14 @@ async function unpublishedExtensionIds(extensionsToml) {

/**
* @param {Record<string, any>} extensionsToml
* @param {string | undefined} compareSha
*/
async function changedExtensionIds(extensionsToml) {
async function changedExtensionIds(extensionsToml, compareSha) {
const { stdout: extensionsContents } = await exec("git", [
"show",
"origin/main:extensions.toml",
compareSha
? `${compareSha}:extensions.toml`
: "origin/main:extensions.toml",
]);
/** @type {any} */
const mainExtensionsToml = toml.parse(extensionsContents);
Expand Down