Skip to content

Commit

Permalink
refactor(ci)!: use l3build tagfiles
Browse files Browse the repository at this point in the history
BREAKING CHANGE: \pgfversiondatetime and \pgfrevisiondatetime have been removed.
BREAKING CHANGE: \pgfversiondate and \pgfrevisiondate now use the format YYYY-MM-DD
BREAKING CHANGE: \pgfrevision{,date} and \pgfversion{,date} are now synonyms

Signed-off-by: Henri Menke <[email protected]>
  • Loading branch information
hmenke committed Dec 17, 2021
1 parent cb61a38 commit 9efb7e4
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 98 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ jobs:
with:
fetch-depth: 0

- name: Install PGF
run: |
tlmgr init-usertree --usertree $PWD
echo "TEXMFHOME=$PWD" >> $GITHUB_ENV
- name: Generate the revision file
run: |
l3build revisionfile
export tagname=$(git describe --abbrev=0 --tags)
export revision=$(git describe --tags)
export tagdate=$(git log -n 1 "$tagname" --pretty=format:%cs)
export revisiondate=$(git log -n 1 "$revision" --pretty=format:%cs)
l3build tag --date "$tagdate" "$tagname"
cat tex/generic/pgf/pgf.revision.tex
echo "GIT_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
- name: Run test suite
run: |
l3build check -q -H --show-log-on-error
l3build check -q --show-log-on-error
14 changes: 6 additions & 8 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ jobs:
with:
fetch-depth: 0

- name: Install PGF
run: |
tlmgr init-usertree --usertree $PWD
echo "TEXMFHOME=$PWD" >> $GITHUB_ENV
- name: Generate the revision file
run: |
l3build revisionfile
export tagname=$(git describe --abbrev=0 --tags)
export revision=$(git describe --tags)
export tagdate=$(git log -n 1 "$tagname" --pretty=format:%cs)
export revisiondate=$(git log -n 1 "$revision" --pretty=format:%cs)
l3build tag --date "$tagdate" "$tagname"
cat tex/generic/pgf/pgf.revision.tex
echo "GIT_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
- name: Build the manual
run: |
l3build doc -q -H
l3build doc -q
- uses: actions/upload-artifact@v2
with:
Expand Down
65 changes: 32 additions & 33 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,22 @@ jobs:
with:
fetch-depth: 0

- name: Install PGF
run: |
tlmgr init-usertree --usertree $PWD
echo "TEXMFHOME=$PWD" >> $GITHUB_ENV
- name: Generate the revision file
run: |
l3build revisionfile
export tagname=$(git describe --abbrev=0 --tags)
export revision=$(git describe --tags)
export tagdate=$(git log -n 1 "$tagname" --pretty=format:%cs)
export revisiondate=$(git log -n 1 "$revision" --pretty=format:%cs)
l3build tag --date "$tagdate" "$tagname"
cat tex/generic/pgf/pgf.revision.tex
echo "GIT_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
echo "tagname=$tagname" >> $GITHUB_ENV
- name: "ZIP: Build"
- name: l3build ctan
run: |
l3build ctan
# rename zips
cp "pgf.tds.zip" "pgf_${GIT_TAG}.tds.zip"
cp "pgf.ctan.flatdir.zip" "pgf_${GIT_TAG}.ctan.flatdir.zip"
cp "pgf.tds.zip" "pgf_${tagname}.tds.zip"
cp "pgf.ctan.flatdir.zip" "pgf_${tagname}.ctan.flatdir.zip"
- uses: actions/upload-artifact@v2
with:
Expand All @@ -45,20 +44,20 @@ jobs:
GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
run: |
# get the keys
printenv GPG_SECRET_KEY > "pgf-${GIT_TAG}.sec"
printenv GPG_PUBLIC_KEY > "pgf-${GIT_TAG}.pub"
printenv GPG_SECRET_KEY > "pgf-${tagname}.sec"
printenv GPG_PUBLIC_KEY > "pgf-${tagname}.pub"
export GNUPGHOME=$(mktemp -d)
install -dm 0700 "$GNUPGHOME"
gpg --import "pgf-${GIT_TAG}.sec"
gpg --armor --output "pgf_${GIT_TAG}.tds.zip.sig" --detach-sign "pgf_${GIT_TAG}.tds.zip"
gpg --armor --output "pgf_${GIT_TAG}.ctan.flatdir.zip.sig" --detach-sign "pgf_${GIT_TAG}.ctan.flatdir.zip"
gpg --import "pgf-${tagname}.sec"
gpg --armor --output "pgf_${tagname}.tds.zip.sig" --detach-sign "pgf_${tagname}.tds.zip"
gpg --armor --output "pgf_${tagname}.ctan.flatdir.zip.sig" --detach-sign "pgf_${tagname}.ctan.flatdir.zip"
rm -rf "$GNUPGHOME"
# verify the signature against the distributed public key
export GNUPGHOME=$(mktemp -d)
install -dm 0700 "$GNUPGHOME"
gpg --import "pgf-${GIT_TAG}.pub"
gpg --verify "pgf_${GIT_TAG}.tds.zip.sig"
gpg --verify "pgf_${GIT_TAG}.ctan.flatdir.zip.sig"
gpg --import "pgf-${tagname}.pub"
gpg --verify "pgf_${tagname}.tds.zip.sig"
gpg --verify "pgf_${tagname}.ctan.flatdir.zip.sig"
rm -rf "$GNUPGHOME"
- name: "Release: create"
Expand All @@ -67,8 +66,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.GIT_TAG }}
release_name: ${{ env.GIT_TAG }}
tag_name: ${{ env.tagname }}
release_name: ${{ env.tagname }}
body_path: doc/generic/pgf/RELEASE_NOTES.md

- name: "Release: upload manual"
Expand All @@ -78,7 +77,7 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/doc/pgfmanual.pdf
asset_name: pgfmanual-${{ env.GIT_TAG }}.pdf
asset_name: pgfmanual-${{ env.tagname }}.pdf
asset_content_type: application/pdf

- name: "Release: upload public key"
Expand All @@ -87,8 +86,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pgf-${{ env.GIT_TAG }}.pub
asset_name: pgf-${{ env.GIT_TAG }}.pub
asset_path: ./pgf-${{ env.tagname }}.pub
asset_name: pgf-${{ env.tagname }}.pub
asset_content_type: text/plain

- name: "Release: upload TDS zip"
Expand All @@ -97,8 +96,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pgf_${{ env.GIT_TAG }}.tds.zip
asset_name: pgf_${{ env.GIT_TAG }}.tds.zip
asset_path: ./pgf_${{ env.tagname }}.tds.zip
asset_name: pgf_${{ env.tagname }}.tds.zip
asset_content_type: application/zip

- name: "Release: upload TDS signature"
Expand All @@ -107,8 +106,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pgf_${{ env.GIT_TAG }}.tds.zip.sig
asset_name: pgf_${{ env.GIT_TAG }}.tds.zip.sig
asset_path: ./pgf_${{ env.tagname }}.tds.zip.sig
asset_name: pgf_${{ env.tagname }}.tds.zip.sig
asset_content_type: text/plain

- name: "Release: upload CTAN zip"
Expand All @@ -117,8 +116,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pgf_${{ env.GIT_TAG }}.ctan.flatdir.zip
asset_name: pgf_${{ env.GIT_TAG }}.ctan.flatdir.zip
asset_path: ./pgf_${{ env.tagname }}.ctan.flatdir.zip
asset_name: pgf_${{ env.tagname }}.ctan.flatdir.zip
asset_content_type: application/zip

- name: "Release: upload CTAN signature"
Expand All @@ -127,15 +126,15 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pgf_${{ env.GIT_TAG }}.ctan.flatdir.zip.sig
asset_name: pgf_${{ env.GIT_TAG }}.ctan.flatdir.zip.sig
asset_path: ./pgf_${{ env.tagname }}.ctan.flatdir.zip.sig
asset_name: pgf_${{ env.tagname }}.ctan.flatdir.zip.sig
asset_content_type: text/plain

- name: "CTAN: Validate"
run: |
l3build upload --debug "$GIT_TAG"
l3build upload --dry-run "$tagname"
- name: "CTAN: Upload"
if: github.repository == 'pgf-tikz/pgf'
run: |
l3build upload "$GIT_TAG"
l3build upload "$tagname"
61 changes: 17 additions & 44 deletions build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ maxprintline = 9999
ctanzip = "pgf.ctan.flatdir"
packtdszip = true

-- if ctanupload is nil or false, only validation is attempted
if options["dry-run"] then
ctanupload = false
end

-- CTAN upload
uploadconfig = {
announcement_file = "doc/generic/pgf/RELEASE_NOTES.md",
Expand All @@ -70,51 +75,19 @@ signature from the GitHub release page
-- version has to be passed on the command line
}

-- For the way pgf does releases
local function trim(str)
return str:gsub("^%s*(.-)%s$", "%1")
end

local function runcmd(cmd)
local pid = assert(io.popen(cmd))
local out = trim(pid:read("*all"))
pid:close()
return out
end

local git = {
tag = runcmd("git describe --abbrev=0 --tags"),
HEAD = runcmd("git rev-parse --abbrev-ref HEAD"),
}

local function revisionfile()
-- Generate the revision file
local revision = runcmd("git describe --tags HEAD")
local versiondatetime = runcmd("git log -n 1 '" .. git.tag .. "' --pretty=format:'%ci'")
local revisiondatetime = runcmd("git log -n 1 '" .. revision .. "' --pretty=format:'%ci'")

local revisionfiletext = [[
\begingroup
\catcode`\-=12
\catcode`\/=12
\catcode`\.=12
\catcode`\:=12
\catcode`\+=12
\catcode`\-=12
\gdef\pgfrevision{%s}
\gdef\pgfversion{%s}
\gdef\pgfversiondatetime{%s}
\gdef\pgfrevisiondatetime{%s}
\gdef\pgf@glob@TMPa#1-#2-#3 #4\relax{#1/#2/#3}
\xdef\pgfversiondate{\expandafter\pgf@glob@TMPa\pgfversiondatetime\relax}
\xdef\pgfrevisiondate{\expandafter\pgf@glob@TMPa\pgfrevisiondatetime\relax}
\endgroup
function tag_hook(tagname, tagdate)
local revision = options["--revision"] or tagname
local revisiondate = options["--revision-date"] or tagdate
local revisionfiletext = [[
\def\pgfrevision{%s}
\def\pgfversion{%s}
\def\pgfrevisiondate{%s}
\def\pgfversiondate{%s}
]]

local revisionfile = io.open(maindir .. "/tex/generic/pgf/pgf.revision.tex", "w")
revisionfile:write(string.format(revisionfiletext, git.tag, revision, versiondatetime, revisiondatetime))
revisionfile:close()
return 0
local file = io.open("tex/generic/pgf/pgf.revision.tex", "w")
file:write(string.format(revisionfiletext, revision, tagname, revisiondate, tagdate))
file:close()
return 0
end

target_list = target_list or { }
Expand Down
8 changes: 3 additions & 5 deletions tex/generic/pgf/utilities/pgfrcs.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
% prints out a message to the log.

\pgfutil@IfFileExists{pgf.revision.tex}{\input pgf.revision.tex } {%
\def\pgfrevision{0}%
\def\pgfrevision{0.0}%
\def\pgfversion{0.0}%
\def\pgfversiondatetime{2014-07-01 00:00:00 +100}%
\def\pgfrevisiondatetime{2014-07-01 00:00:00 +100}%
\def\pgfversiondate{2014/07/01}%
\def\pgfrevisiondate{2014/07/01}%
\def\pgfversiondate{2014-07-01}%
\def\pgfrevisiondate{2014-07-01}%
}

\begingroup
Expand Down

0 comments on commit 9efb7e4

Please sign in to comment.