Skip to content

Commit a0230b9

Browse files
authored
feat(core): Detect releases from more providers (#549)
1 parent 4534093 commit a0230b9

File tree

1 file changed

+71
-14
lines changed
  • packages/bundler-plugin-core/src

1 file changed

+71
-14
lines changed

Diff for: packages/bundler-plugin-core/src/utils.ts

+71-14
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,61 @@ function gitRevision(): string | undefined {
209209
* Tries to guess a release name based on environmental data.
210210
*/
211211
export function determineReleaseName(): string | undefined {
212-
return (
212+
// This list is in approximate alpha order, separated into 3 categories:
213+
// 1. Git providers
214+
// 2. CI providers with specific environment variables (has the provider name in the variable name)
215+
// 3. CI providers with generic environment variables (checked for last to prevent possible false positives)
216+
217+
const possibleReleaseNameOfGitProvider =
213218
// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
214219
process.env["GITHUB_SHA"] ||
215-
// Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
216-
process.env["COMMIT_REF"] ||
217-
// Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
218-
process.env["CF_PAGES_COMMIT_SHA"] ||
220+
// GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
221+
process.env["CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"] ||
222+
process.env["CI_BUILD_REF"] ||
223+
process.env["CI_COMMIT_SHA"] ||
224+
// Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
225+
process.env["BITBUCKET_COMMIT"];
226+
227+
const possibleReleaseNameOfCiProvidersWithSpecificEnvVar =
228+
// AppVeyor - https://www.appveyor.com/docs/environment-variables/
229+
process.env["APPVEYOR_PULL_REQUEST_HEAD_COMMIT"] ||
230+
process.env["APPVEYOR_REPO_COMMIT"] ||
219231
// AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
220232
process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] ||
221-
// Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
222-
process.env["BITBUCKET_COMMIT"] ||
223-
// CircleCI - https://circleci.com/docs/2.0/env-vars/
233+
// AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html
234+
process.env["AWS_COMMIT_ID"] ||
235+
// Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
236+
process.env["BUILD_SOURCEVERSION"] ||
237+
// Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/
238+
process.env["GIT_CLONE_COMMIT_HASH"] ||
239+
// Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables
240+
process.env["BUDDY_EXECUTION_REVISION"] ||
241+
// Builtkite - https://buildkite.com/docs/pipelines/environment-variables
242+
process.env["BUILDKITE_COMMIT"] ||
243+
// CircleCI - https://circleci.com/docs/variables/
224244
process.env["CIRCLE_SHA1"] ||
245+
// Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables
246+
process.env["CIRRUS_CHANGE_IN_REPO"] ||
247+
// Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/
248+
process.env["CF_REVISION"] ||
249+
// Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/
250+
process.env["CM_COMMIT"] ||
251+
// Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
252+
process.env["CF_PAGES_COMMIT_SHA"] ||
253+
// Drone - https://docs.drone.io/pipeline/environment/reference/
254+
process.env["DRONE_COMMIT_SHA"] ||
255+
// Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
256+
process.env["FC_GIT_COMMIT_SHA"] ||
257+
// Heroku #1 https://devcenter.heroku.com/articles/heroku-ci
258+
process.env["HEROKU_TEST_RUN_COMMIT_VERSION"] ||
259+
// Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases
260+
process.env["HEROKU_SLUG_COMMIT"] ||
261+
// Render - https://render.com/docs/environment-variables
262+
process.env["RENDER_GIT_COMMIT"] ||
263+
// Semaphore CI - https://docs.semaphoreci.com/ci-cd-environment/environment-variables
264+
process.env["SEMAPHORE_GIT_SHA"] ||
265+
// TravisCI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
266+
process.env["TRAVIS_PULL_REQUEST_SHA"] ||
225267
// Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
226268
process.env["VERCEL_GIT_COMMIT_SHA"] ||
227269
process.env["VERCEL_GITHUB_COMMIT_SHA"] ||
@@ -230,13 +272,28 @@ export function determineReleaseName(): string | undefined {
230272
// Zeit (now known as Vercel)
231273
process.env["ZEIT_GITHUB_COMMIT_SHA"] ||
232274
process.env["ZEIT_GITLAB_COMMIT_SHA"] ||
233-
process.env["ZEIT_BITBUCKET_COMMIT_SHA"] ||
234-
// Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
235-
process.env["FC_GIT_COMMIT_SHA"] ||
236-
// Heroku #1 https://devcenter.heroku.com/changelog-items/630
275+
process.env["ZEIT_BITBUCKET_COMMIT_SHA"];
276+
277+
const possibleReleaseNameOfCiProvidersWithGenericEnvVar =
278+
// CloudBees CodeShip - https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables
279+
process.env["CI_COMMIT_ID"] ||
280+
// Coolify - https://coolify.io/docs/knowledge-base/environment-variables
281+
process.env["SOURCE_COMMIT"] ||
282+
// Heroku #3 https://devcenter.heroku.com/changelog-items/630
237283
process.env["SOURCE_VERSION"] ||
238-
// Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases
239-
process.env["HEROKU_SLUG_COMMIT"] ||
284+
// Jenkins - https://plugins.jenkins.io/git/#environment-variables
285+
process.env["GIT_COMMIT"] ||
286+
// Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
287+
process.env["COMMIT_REF"] ||
288+
// TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html
289+
process.env["BUILD_VCS_NUMBER"] ||
290+
// Woodpecker CI - https://woodpecker-ci.org/docs/usage/environment
291+
process.env["CI_COMMIT_SHA"];
292+
293+
return (
294+
possibleReleaseNameOfGitProvider ||
295+
possibleReleaseNameOfCiProvidersWithSpecificEnvVar ||
296+
possibleReleaseNameOfCiProvidersWithGenericEnvVar ||
240297
gitRevision()
241298
);
242299
}

0 commit comments

Comments
 (0)