[latex3-commits] [git/LaTeX3-latex3-latex3] gh-release: Add release system for GH Actions (0a87a45b0)

Marcel Fabian Krüger tex at 2krueger.de
Wed Aug 11 03:43:31 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : gh-release
Link       : https://github.com/latex3/latex3/commit/0a87a45b0f06d7018818c9e2453ef5c8930442ca

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

commit 0a87a45b0f06d7018818c9e2453ef5c8930442ca
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Tue Aug 10 16:49:23 2021 +0200

    Add release system for GH Actions


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

0a87a45b0f06d7018818c9e2453ef5c8930442ca
 .github/workflows/{main.yaml => deploy.yaml} | 106 ++++++++++++---------------
 .github/workflows/main.yaml                  |   7 +-
 2 files changed, 53 insertions(+), 60 deletions(-)

diff --git a/.github/workflows/main.yaml b/.github/workflows/deploy.yaml
similarity index 50%
copy from .github/workflows/main.yaml
copy to .github/workflows/deploy.yaml
index 0dcee6d1e..f11127492 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/deploy.yaml
@@ -1,38 +1,17 @@
-name: Automated testing
+name: Create release
 
-# Currently we run in two situations:
+# We create releases for all new tags
 on:
-  # Whenever someone pushes to a branch or tag in our repo
   push:
-  # Whenever a pull request is opened, reopened or gets new commits.
-  pull_request:
-# This implies that for every push to a local branch in our repo for which a
-# pull request is open this runs twice. But it's important to ensure that pull
-# requests get tested even if their branch comes from a fork.
+    tags:
+      - "*"
 
 jobs:
-  # The l3build job contains the actual work. We misuse the matrix mechanism to
-  # create three jobs which only differ in minimal elements.
-  l3build:
+  # The l3build job contains the actual work. This is mostly the same as in main.yaml
+  # and should stay synchronized. Sadly it doesn't seem possible to reuse the instructions at the moment.
+  release:
     runs-on: ubuntu-20.04
-    strategy:
-      matrix:
-        # include indicates that we want to set explicitly these combinations
-        # and don't want full matrix testing.
-        # "name" is just to make the output more readable.
-        # "l3build_cmd" is the actual command to run
-        # "artifact_name" is which artifact might get generated by this step.
-        # IMPORTANT: artifact_name == "Documentation" is used as a trigger to
-        # generate the artifact from PDF files and not the build directory and
-        # to generate the artifact when the run is successful, not when it fails.
-        include:
-          - name: "Test suite"
-            l3build_cmd: l3build check -q -H --show-log-on-error
-            artifact_name: testfiles
-          - name: "Documentation"
-            l3build_cmd: l3build doc -q -H
-            artifact_name: Documentation
-    name: ${{matrix.name }}
+    name: Build release
     steps:
       # Boilerplate
       - name: Checkout repository
@@ -66,40 +45,34 @@ jobs:
           # different workflows.
           package_file: .github/tl_packages
       - name: Run l3build
-        run: ${{ matrix.l3build_cmd }}
-      # Now we create the artifacts: There are two cases where this happens.
-      # 1. If we failed running tests
+        run: l3build ctan -q -H --show-log-on-error
       - name: Archive failed test output
-        if: ${{ matrix.artifact_name != 'Documentation' && failure() }}
+        if: ${{ failure() }}
         uses: actions/upload-artifact at v2
         with:
-          name: ${{ matrix.artifact_name }}
+          name: testfiles
           path: build/test*/*.diff
           # Decide how long to keep the test output artifact:
           retention-days: 3
-      # 2. If we succeed building documentation
-      - name: Archive documentation
-        if: ${{ matrix.artifact_name == 'Documentation' && success() }}
-        uses: actions/upload-artifact at v2
+      # Now create the release (this only runs if the previous steps were successful
+      - name: Create GitHub release
+        uses: ncipollo/release-action at 880be3d0a71bc0fa98db60201d2cbdc27324f547
+        id: release
         with:
-          name: ${{ matrix.artifact_name }}
-          path: "**/*.pdf"
-          # Decide how long to keep the test output artifact:
-          retention-days: 21
-  # GitHub automatically informs the initiator of any action about the result, but
-  # we additionally want to keep the latex-commits mailing list informed about
-  # test failures.
-  notifiy:
-    name: Send notifications
-    runs-on: ubuntu-20.04
-    # Run after the `l3build` job in order to be able to react to it's output.
-    needs: l3build
-    # Only run if the tests failed, we don't want to get notifications for every run.
-    # We don't want information for pull requests since for pull requests from local
-    # branches we already send notifications when the branch test fails and pull requests
-    # from forks can't access the username and password secrets required to send mails.
-    if: ${{ failure() && github.event_name != 'pull_request' }}
-    steps:
+          artifacts: "build/distrib/ctan/*.zip"
+          token: ${{ secrets.GITHUB_TOKEN }}
+      # Determine the name of the tag we are working on. Sadly GH Actions only provides
+      # github.ref which has the name prefixed with github.ref and no way to remove a prefix
+      # in normal expressions, so we need an action for that.
+      - name: Get name
+        uses: frabert/replace-string-action at 9b62dfe3ae936b1cc380f2421c8ac9e63a4a3e85
+        id: name
+        if: ${{ always() }}
+        with:
+          pattern: "^refs/(?:heads|tags)/"
+          string: ${{ github.ref }}
+          replace-with: ""
+      # While the normal notification job only informs about failed runs, we additionally want to notify about successful releases.
       - name: Send mail
         # The explicit commit hash ensures that this can't be used by dawidd6 as a
         # backdoor to execute arbitrary code during our runs.
@@ -118,14 +91,31 @@ jobs:
           # coordinate it with the administrator of the mail server to allow the account
           # to send from the mail address.
           from: LaTeX CI <github at latex-project.org>
+          # Determine the subject and body of the mail.
+          subject: "Version ${{steps.name.outputs.replaced}} of ${{github.repository}} has been released"
+          body: |
+            The release ${{steps.name.outputs.replaced}} has been created for ${{github.repository}}.
+
+            More information can be found at
+            ${{steps.release.outputs.html_url}}
+      - name: Send failure notification
+        uses: dawidd6/action-send-mail at ceb614a2c5737d913f2d2729e2bcc70ad933382b
+        if: ${{ failure() }}
+        with:
+          server_address: typesetting.eu
+          server_port: 587
+          username: ${{secrets.MAIL_USERNAME}}
+          password: ${{secrets.MAIL_PASSWORD}}
+          to: latex3-commits at tug.org
+          from: LaTeX CI <github at latex-project.org>
           priority: high
           # Determine the subject and body of the mail.
-          subject: "Test failed: ${{github.repository}} (${{github.ref}})"
+          subject: "Test failure while trying to build release ${{steps.name.outputs.replaced}} in ${{github.repository}}"
           body: |
             Test failure for ${{github.repository}}
             -------------------------------------------------------------
 
-            On branch:        ${{github.ref}} (${{github.sha}})
+            On tag:           ${{steps.name.outputs.replaced}} (${{github.sha}})
             Initiated by:     ${{github.actor}}
             Commit URL:       https://github.com/${{github.repository}}/commit/${{github.sha}}
             More information: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index 0dcee6d1e..54ffc1bba 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -2,8 +2,10 @@ name: Automated testing
 
 # Currently we run in two situations:
 on:
-  # Whenever someone pushes to a branch or tag in our repo
+  # Whenever someone pushes to a branch in our repo
   push:
+    branches:
+      - "*"
   # Whenever a pull request is opened, reopened or gets new commits.
   pull_request:
 # This implies that for every push to a local branch in our repo for which a
@@ -13,6 +15,7 @@ on:
 jobs:
   # The l3build job contains the actual work. We misuse the matrix mechanism to
   # create three jobs which only differ in minimal elements.
+  # For tags we do not run this since we run the release job instead.
   l3build:
     runs-on: ubuntu-20.04
     strategy:
@@ -32,7 +35,7 @@ jobs:
           - name: "Documentation"
             l3build_cmd: l3build doc -q -H
             artifact_name: Documentation
-    name: ${{matrix.name }}
+    name: ${{ matrix.name }}
     steps:
       # Boilerplate
       - name: Checkout repository





More information about the latex3-commits mailing list.