[latex3-commits] [git/LaTeX3-latex3-latex2e] develop, main: Fix detection of main/dev branch on GitHub Actions (2feea850)

Marcel Fabian Krüger tex at 2krueger.de
Fri Nov 12 11:02:52 CET 2021


Repository : https://github.com/latex3/latex2e
On branches: develop,main
Link       : https://github.com/latex3/latex2e/commit/2feea85051c5cf7c6d037a9f14a0d3bebbed32ac

>---------------------------------------------------------------

commit 2feea85051c5cf7c6d037a9f14a0d3bebbed32ac
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Fri Nov 12 11:02:52 2021 +0100

    Fix detection of main/dev branch on GitHub Actions


>---------------------------------------------------------------

2feea85051c5cf7c6d037a9f14a0d3bebbed32ac
 build-config.lua | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/build-config.lua b/build-config.lua
index 0ce17318..d3fd14d1 100644
--- a/build-config.lua
+++ b/build-config.lua
@@ -69,20 +69,22 @@ end
 
 -- Allow for 'dev' release
 --
--- See stackoverflow.com/a/12142066/212001
--- Also luaotfload build.lua: getting the Travis-CI version right is 'fun'
+-- See https://docs.github.com/en/actions/learn-github-actions/environment-variables
+-- for the meaning of the environment variables, but tl;dr: GITHUB_REF_TYPE says
+-- if we have a tag or a branch, GITHUB_REF_NAME has the corresponding name.
+-- If either one of them isn't set, we look at the current git HEAD.
 do
-  local tag = os.getenv'TRAVIS_TAG'
-  if tag and tag ~= "" then
-    main_branch = not string.match(tag, '^dev-')
+  local gh_type = os.getenv'GITHUB_REF_TYPE'
+  local name = os.getenv'GITHUB_REF_NAME'
+  if gh_type == 'tag' and name then
+    main_branch = not string.match(name, '^dev-')
   else
-    local branch = os.getenv'TRAVIS_BRANCH'
-    if not branch then
+    if gh_type ~= 'branch' or not name then
       local f = io.popen'git rev-parse --abbrev-ref HEAD'
-      branch = f:read'*a':sub(1,-2)
+      name = f:read'*a':sub(1,-2)
       assert(f:close())
     end
-    main_branch = string.match(branch, '^main')
+    main_branch = string.match(name, '^main')
   end
   if not main_branch then
     tdsroot = "latex-dev"





More information about the latex3-commits mailing list.