From 9a608b393ab3d67747dda6ec2ee17d53fb5b0bb6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 20 Mar 2024 14:39:20 +0900 Subject: [PATCH] Automate release process --- .github/workflows/build.yml | 70 +++++++++++++++++++++++++++++++++++++ makerelease.sh | 12 +++---- 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e1d0ac..a585632 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -167,3 +167,73 @@ jobs: run: | cmake --build build cmake --build build --target check + + release: + if: github.ref_type == 'tag' + + needs: + - build + - build-cross + - build-windows + + permissions: + contents: write + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + - name: Make artifacts + run: | + ver='${{ github.ref_name }}' + + prev_ver=$(git tag --sort v:refname | grep -v -F "${ver}" | \ + grep 'v[0-9]\+\.[0-9]\+\.0' | tail -n1) + + echo -n "$GPG_KEY" | gpg --batch --pinentry-mode loopback --import + ./makerelease.sh "${ver}" "${prev_ver}" + env: + GPG_KEY: ${{ secrets.GPG_KEY }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + - name: Make release + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs') + + let ver = '${{ github.ref_name }}' + + let {data: release} = await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: ver, + name: `nghttp3 ${ver}`, + draft: true, + generate_release_notes: true, + discussion_category_name: 'Announcements', + }) + + let v = ver.substring(1) + + let files = [ + 'checksums.txt', + `nghttp3-${v}.tar.bz2`, + `nghttp3-${v}.tar.bz2.asc`, + `nghttp3-${v}.tar.gz`, + `nghttp3-${v}.tar.gz.asc`, + `nghttp3-${v}.tar.xz`, + `nghttp3-${v}.tar.xz.asc`, + ] + + await Promise.all(files.map(elem => + github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.id, + name: elem, + data: fs.readFileSync(elem), + }) + )) diff --git a/makerelease.sh b/makerelease.sh index 28d563e..7b328be 100755 --- a/makerelease.sh +++ b/makerelease.sh @@ -6,17 +6,17 @@ PREV_TAG=$2 git checkout refs/tags/$TAG git log --pretty=fuller --date=short refs/tags/$PREV_TAG..HEAD > ChangeLog -git submodule update --init --depth 1 - autoreconf -i -./configure && \ - make dist-bzip2 && make dist-gzip && make dist-xz || echo "error" +./configure +make dist-bzip2 +make dist-gzip +make dist-xz make distclean rm -f checksums.txt -VERSION=`echo -n $TAG | sed -E 's|^v([0-9]+\.[0-9]+\.[0-9]+)(-DEV)?$|\1|'` +VERSION=`echo -n $TAG | sed -E 's|^v([0-9]+\.[0-9]+\.[0-9]+(-[^.]+(\.[0-9]+)?)?)$|\1|'` for f in nghttp3-$VERSION.tar.bz2 nghttp3-$VERSION.tar.gz nghttp3-$VERSION.tar.xz; do sha256sum $f >> checksums.txt - gpg --armor --detach-sign $f + echo -n "$GPG_PASSPHRASE" | gpg --batch --passphrase-fd 0 --pinentry-mode loopback --armor --detach-sign $f done