Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,7 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- name: "Determine release tag"
run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"

- name: "Determine release body"
uses: "actions/github-script@v5"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const repository = context.repo;

const response = await github.rest.repos.generateReleaseNotes({
owner: repository.owner,
repo: repository.repo,
tag_name: "${{ env.RELEASE_TAG }}",
});

core.exportVariable("RELEASE_BODY", response.data.body);

- name: "Create release"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/release/create@main"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const repository = context.repo;

await github.rest.repos.createRelease({
body: "${{ env.RELEASE_BODY }}",
draft: false,
name: "${{ env.RELEASE_TAG }}",
owner: repository.owner,
prerelease: false,
repo: repository.repo,
tag_name: "${{ env.RELEASE_TAG }}",
});
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For a full diff see [`1.2.1...main`][1.2.1...main].
- Added composite action `github/pull-request/approve` ([#60]), by [@localheinz]
- Added composite action `github/pull-request/merge` ([#64]), by [@localheinz]
- Added composite action `github/pull-request/add-label-based-on-branch-name` ([#67]), by [@localheinz]
- Added composite action `github/release/create` ([#72]), by [@localheinz]

## [`1.2.1`][1.2.1]

Expand Down Expand Up @@ -66,5 +67,6 @@ For a full diff see [`1.0.0...main`][1.0.0...main].
[#60]: https://github.com/ergebnis/.github/pull/60
[#64]: https://github.com/ergebnis/.github/pull/64
[#67]: https://github.com/ergebnis/.github/pull/67
[#72]: https://github.com/ergebnis/.github/pull/72

[@localheinz]: https://github.com/localheinz
48 changes: 48 additions & 0 deletions actions/github/release/create/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions
# https://docs.github.com/en/rest/reference/releases#create-a-release
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push

name: "Create a release"

description: "Creates a release"

inputs:
github-token:
description: "GitHub token of a user with permission to create a release"
required: true

runs:
using: "composite"

steps:
- name: "Determine tag"
if: "${{ github.event_name }} == 'push' && ${{ github.ref_type }} == 'tag'"
run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
shell: "bash"

- name: "Create release"
uses: "actions/github-script@v5"
with:
github-token: "${{ inputs.github-token }}"
script: |
if (!process.env.RELEASE_TAG) {
core.setFailed("The environment variable RELEASE_TAG is not defined.")

return;
}

try {
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
} catch (error) {
core.setFailed(error.message);
}