Skip to content

Commit cf85c7c

Browse files
committed
Use API to generate changelog for PECL package
1 parent d804694 commit cf85c7c

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

.github/workflows/commit-and-tag.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ set -e
33

44
PACKAGE_VERSION=$1
55
GPG_KEY_ID=$2
6-
TAG_MESSAGE_FILE=$3
76

87
gpgloader
98

@@ -13,4 +12,4 @@ git commit -m "Package ${PACKAGE_VERSION}" -s --gpg-sign=${GPG_KEY_ID} phongo_ve
1312

1413
# Create signed "Release x.y.z" tag
1514
echo "Create release tag"
16-
git tag -F ${TAG_MESSAGE_FILE} -s --local-user=${GPG_KEY_ID} ${PACKAGE_VERSION}
15+
git tag -m "Release ${PACKAGE_VERSION}" -s --local-user=${GPG_KEY_ID} ${PACKAGE_VERSION}

.github/workflows/package-release.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
runs-on: "ubuntu-latest"
1717
permissions:
1818
id-token: write
19+
contents: write
1920

2021
steps:
2122
- name: "Generate token and checkout repository"
@@ -39,7 +40,13 @@ jobs:
3940
version: "8.3"
4041

4142
- name: "Write changelog file for packaging"
42-
run: git tag -l ${{ github.ref_name }} --format='%(contents)' > changelog
43+
run: |
44+
gh api \
45+
--method POST \
46+
-H "Accept: application/vnd.github+json" \
47+
-H "X-GitHub-Api-Version: 2022-11-28" \
48+
/repos/${{ github.repository }}/releases/generate-notes \
49+
-f "tag_name=${{ inputs.ref }}" --jq '.body' > changelog
4350
4451
# This will fill in the release notes from the previously generated changelog
4552
- name: "Build package.xml"

.github/workflows/release.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,13 @@ jobs:
9393
# Preliminary checks done - commence the release process
9494
#
9595

96-
# Create a draft release with a changelog
97-
# TODO: Consider using the API to generate changelog
98-
- name: "Create draft release with generated changelog"
99-
run: gh release create ${{ env.PACKAGE_VERSION }} --target ${{ github.ref_name }} --generate-notes --draft
100-
101-
- name: "Read changelog from draft release"
102-
run: gh release view ${{ env.PACKAGE_VERSION }} --json body --template '{{ .body }}' >> changelog
103-
104-
- name: "Prepare tag message"
105-
run: |
106-
echo -e "Release ${PACKAGE_VERSION}\n" > tag-message
107-
cat changelog >> tag-message
108-
10996
# This step creates the "Package x.y.z" commit that will be the base of
11097
# our tag and creates the release tag. This is run inside the container in
11198
# order to create signed git artifacts
11299
- name: "Create package commit and release tag"
113100
uses: mongodb-labs/drivers-github-tools/git-sign@v2
114101
with:
115-
command: "$(pwd)/.github/workflows/commit-and-tag.sh ${{ env.PACKAGE_VERSION }} ${{ env.GPG_KEY_ID }} tag-message"
102+
command: "$(pwd)/.github/workflows/commit-and-tag.sh ${{ inputs.version }} ${{ env.GPG_KEY_ID }}"
116103

117104
# This step needs to happen outside of the container, as PHP is not
118105
# available within.
@@ -138,16 +125,14 @@ jobs:
138125
- name: "Prepare release message"
139126
run: |
140127
cat > release-message <<'EOL'
141-
${{ format(env.default-release-message, env.PACKAGE_VERSION, inputs.jira-version-number) }}
128+
${{ format(env.default-release-message, inputs.version, inputs.jira-version-number) }}
142129
EOL
143-
cat changelog >> release-message
144130
145-
# Update release with correct release information
146-
- name: "Update release information"
147-
run: echo "RELEASE_URL=$(gh release edit ${{ env.PACKAGE_VERSION }} --title "${{ env.PACKAGE_VERSION }}" --notes-file release-message)" >> "$GITHUB_ENV"
131+
- name: "Create draft release"
132+
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ github.ref_name }} --title "${{ inputs.version }}" --notes-file release-message --draft)" >> "$GITHUB_ENV"
148133

149134
- name: "Push release tag"
150-
run: git push origin ${{ env.PACKAGE_VERSION }}
135+
run: git push origin ${{ inputs.version }}
151136

152137
- name: "Set summary"
153138
run: |
@@ -173,6 +158,7 @@ jobs:
173158
secrets: inherit
174159
permissions:
175160
id-token: write
161+
contents: write
176162

177163
publish-ssdlc-assets:
178164
needs:

0 commit comments

Comments
 (0)