]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
Add a release workflow
authorMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 21 Jan 2023 13:49:40 +0000 (14:49 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 21 Jan 2023 14:55:24 +0000 (15:55 +0100)
Should be auto-filling the release information and upload
a source distro package tarball.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
.github/workflows/gen_release.pl [new file with mode: 0755]
.github/workflows/on_tag.yml [new file with mode: 0644]

diff --git a/.github/workflows/gen_release.pl b/.github/workflows/gen_release.pl
new file mode 100755 (executable)
index 0000000..75a698e
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+my $body_path = shift or die "Need a file name to store the release body";
+
+my $ver;
+
+open IN, "configure.ac" or die;
+while (<IN>) {
+       if (m/^[^\#]*AC_INIT\s*\(\s*\[\s*RASdaemon\s*\]\s*,\s*\[?(\d+[\.\d]+)/) {
+               $ver=$1;
+               last;
+       }
+}
+close IN or die "can't open configure.ac";
+
+die "Can't get version from configure.ac" if (!$ver);
+
+sub gen_version() {
+       print "$ver\n";
+
+       open IN, "ChangeLog" or return "error opening ChangeLog";
+       open OUT, ">$body_path" or return "error creating $body_path";
+       while (<IN>) {
+               last if (m/$ver/);
+       }
+       while (<IN>) {
+               next if (m/^$/);
+               last if (m/^\S/);
+
+               my $ln = $_;
+               $ln =~ s/^\s+\*/-/;
+               print OUT $ln;
+       }
+       close OUT or return "error closing $body_path";
+
+       return "";
+}
+
+my $ret = gen_version();
+
+die($ret) if ($ret ne "");
diff --git a/.github/workflows/on_tag.yml b/.github/workflows/on_tag.yml
new file mode 100644 (file)
index 0000000..6cc33eb
--- /dev/null
@@ -0,0 +1,44 @@
+name: Create release on tag
+
+on:
+  workflow_dispatch:
+  push:
+    # Sequence of patterns matched against refs/tags
+    tags:
+      - 'v[0-9]+*'
+
+jobs:
+  release:
+    name: Create Release
+    runs-on: ubuntu-latest
+    outputs:
+      upload_url: ${{ steps.create_release.outputs.upload_url }}
+    steps:
+      - uses: actions/checkout@v2
+      - name: Release changelog
+        run: |
+          .github/workflows/gen_release.pl body_file.tmp > version
+      - name: Create Release
+        id: create_release
+        uses: actions/create-release@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: ${{ github.ref }}
+          release_name: Release ${{ github.ref }}
+          body_path: body_file.tmp
+          draft: false
+          prerelease: true
+      - name: Create Source Package
+        run: |
+          autoreconf -vfi
+          ./configure --enable-all
+          make dist-bzip2
+          mkdir artifacts
+          mv rasdaemon-$(cat version).tar.bz2 artifacts
+      - name: Archive package
+        uses: actions/upload-artifact@v1
+        with:
+          name: rasdaemon-source-package
+          path: artifacts/
+