Skip to content

Commit

Permalink
Merge pull request #210 from ngtcp2/automate-release
Browse files Browse the repository at this point in the history
Automate release process
  • Loading branch information
tatsuhiro-t authored Mar 20, 2024
2 parents 9515546 + 9a608b3 commit 296b526
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 6 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
))
12 changes: 6 additions & 6 deletions makerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 296b526

Please sign in to comment.