Browse Source

ci: fix changelog generation

Kévin Dunglas 1 year ago
parent
commit
7c5f18fe3f
3 changed files with 21 additions and 33 deletions
  1. 8 30
      .github/workflows/static.yaml
  2. 1 1
      frankenphp.go
  3. 12 2
      release.sh

+ 8 - 30
.github/workflows/static.yaml

@@ -14,18 +14,6 @@ on:
   schedule:
     - cron:  '0 0 * * *'  
 jobs:
-  release:
-    if: github.ref_type == 'tag'
-    name: Create GitHub Release
-    runs-on: ubuntu-latest
-    steps:
-      - name: Create release
-        uses: ncipollo/release-action@v1
-        with:
-          generateReleaseNotes: true
-          allowUpdates: true
-          omitBodyDuringUpdate: true
-          omitNameDuringUpdate: true
   prepare:
     runs-on: ubuntu-latest
     outputs:
@@ -36,6 +24,8 @@ jobs:
         id: ref
         if: github.event_name == 'schedule'
         run: echo ref="$(gh release view --repo dunglas/frankenphp --json tagName --jq '.tagName')" >> "${GITHUB_OUTPUT}"
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
   build-linux:
     name: Build Linux x86_64 binary
     runs-on: ubuntu-latest
@@ -84,15 +74,9 @@ jobs:
       -
         name: Upload asset
         if: github.event_name == 'schedule' || github.ref_type == 'tag'
-        uses: ncipollo/release-action@v1
-        with:
-          tag: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }} 
-          generateReleaseNotes: true
-          allowUpdates: true
-          omitBodyDuringUpdate: true
-          omitNameDuringUpdate: true
-          artifacts: frankenphp-linux-x86_64
-          replacesArtifacts: true
+        run: gh release upload "${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}" frankenphp-linux-x86_64 --repo dunglas/frankenphp --clobber
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
       -
         name: Upload artifact
         if: github.ref_type == 'branch'
@@ -138,15 +122,9 @@ jobs:
       -
         name: Upload asset
         if: github.event_name == 'schedule' || github.ref_type == 'tag'
-        uses: ncipollo/release-action@v1
-        with:
-          tag: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}
-          generateReleaseNotes: true
-          allowUpdates: true
-          omitBodyDuringUpdate: true
-          omitNameDuringUpdate: true
-          artifacts: dist/frankenphp-mac-x86_64
-          replacesArtifacts: true
+        run: gh release upload "${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}" dist/frankenphp-mac-x86_64 --repo dunglas/frankenphp --clobber
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
       -
         name: Upload artifact
         if: github.ref_type == 'branch'

+ 1 - 1
frankenphp.go

@@ -7,7 +7,7 @@ package frankenphp
 
 //go:generate rm -Rf C-Thread-Pool/
 //go:generate git clone --depth=1 git@github.com:Pithikos/C-Thread-Pool.git
-//go:generate rm -Rf C-Thread-Pool/.git C-Thread-Pool/.circleci C-Thread-Pool/docs C-Thread-Pool/tests C-Thread-Pool/example.c
+//go:generate rm -Rf C-Thread-Pool/.git C-Thread-Pool/.github C-Thread-Pool/docs C-Thread-Pool/tests C-Thread-Pool/example.c
 
 // Use PHP includes corresponding to your PHP installation by running:
 //

+ 12 - 2
release.sh

@@ -14,7 +14,12 @@ if ! type "git" > /dev/null; then
     exit 1
 fi
 
-if [ $# -ne 1 ]; then
+if ! type "gh" > /dev/null; then
+    echo "The \"gh\" command must be installed."
+    exit 1
+fi
+
+if [[ $# -ne 1 ]]; then
     echo "Usage: ./release.sh version" >&2
     exit 1
 fi
@@ -38,7 +43,12 @@ git tag -s -m "Version $1" "v$1"
 git tag -s -m "Version $1" "caddy/v$1"
 git push --follow-tags
 
-if [ "$(uname -s)" = "Darwin" ]; then
+tags=$(git tag --list --sort=-version:refname 'v*')
+previous_tag=$(awk 'NR==2 {print;exit}' <<< "${tags}")
+
+gh release create --draft --generate-notes --latest --notes-start-tag "${previous_tag}" --verify-tag "v$1"
+
+if [[ "$(uname -s)" = "Darwin" ]]; then
     rm -Rf dist/*
     FRANKENPHP_VERSION=$1 RELEASE=1 ./build-static.sh
 fi