From cea4696ac06dfb8c0276daf23cbd7d4a2e89f5a3 Mon Sep 17 00:00:00 2001 From: Johan Larsson Date: Fri, 12 Jan 2024 12:44:23 +0100 Subject: [PATCH] build: use release-please and auto tagging --- .github/workflows/ci.yml | 46 +++++++++++++++++++++++++++++++---- .release-please-manifest.json | 3 +++ build.lua | 35 ++++++++++++++------------ release-please-config.json | 8 ++++++ version.txt | 1 + 5 files changed, 73 insertions(+), 20 deletions(-) create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json create mode 100644 version.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ab7f70..7d3b036 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,15 +7,51 @@ on: branches: - main jobs: - build: + build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: teatimeguest/setup-texlive-action@v3 with: packages: scheme-full - - name: Build and test LaTeX package + - name: check + run: l3build check + - name: document + run: l3build doc + - name: install + run: l3build install + release: + if: ${{ github.ref == 'refs/heads/main' }} + permissions: + contents: write + pull-requests: write + needs: + - build-and-test + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v4 + with: + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + release-type: simple + - uses: actions/checkout@v4 + if: ${{ steps.release.outputs.prs_created }} + - uses: teatimeguest/setup-texlive-action@v3 + with: + packages: scheme-basic + if: ${{ steps.release.outputs.prs_created }} + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: refs/pull/${{ steps.release.outputs.pr.number }}/merge + if: ${{ steps.release.outputs.prs_created }} + - name: tag + run: l3build tag 0.1.0 + if: ${{ steps.release.outputs.prs_created }} + - name: Commit and push run: | - l3build check - l3build doc - l3build install + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add . + git commit -m "chore: tag files" + git push + if: ${{ steps.release.outputs.prs_created }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..466df71 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} diff --git a/build.lua b/build.lua index 5e8a405..861fb0f 100644 --- a/build.lua +++ b/build.lua @@ -2,20 +2,25 @@ module = "moloch" --- sourcefiledir = "src" --- --- installfiles = {"*.sty"} --- sourcefiles = {"src/*.dtx"} --- typesetfiles = {"src/*.dtx"} - sourcefiledir = "src" --- docfiledir = "docs" --- unpackfiles = { "*.dtx" } --- -- typesetfiles = { "*.dtx", "*.tex" } --- typesetfiles = { "moloch.dtx" } --- installfiles = {"*.sty", "*.dtx"} --- packtdszip = true +typesetfiles = { "doc/moloch.tex" } -typesetfiles = {"doc/moloch.tex"} --- sourcefiles = {"src/*.dtx"} --- docfiles = {"doc/*.tex"} +function update_tag(file, content, tagname, tagdate) + if string.match(file, "%.dtx$") then + local pattern = "\\ProvidesPackage{(.-)}%[([^%]]-) v([^%]]-) ([^%]]-)%]" + return content:gsub( + pattern, + function(package_name, old_date, old_version, description) + return string.format( + "\\ProvidesPackage{%s}[%s v%s %s]", + package_name, + tagdate, + tagname, + description + ) + end + ) + end + + return content +end diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..3e23caf --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,8 @@ +{ + "packages": { + ".": { + "release-type": "simple", + "bump-minor-pre-major": true + } + } +} diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.1.0