Skip to content

Commit

Permalink
Merge pull request #11 from creative-commoners/pulls/1/patch
Browse files Browse the repository at this point in the history
NEW Auto notes
  • Loading branch information
GuySartorelli authored Jul 2, 2023
2 parents f113ee2 + 81a6031 commit 2960d8c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,30 @@ Create a tag and an optional release
```yml
steps:
- name: Create tag and release
uses: silverstripe/gha-pull-request@v1
uses: silverstripe/gha-tag-release@v1
with:
tag: 1.2.3
release: true
```
Read more information about the inputs available for [silverstripe/gha-pull-request](https://github.com/silverstripe/gha-pull-request).
### Inputs
#### tag (required)
The tag to create e.g. 1.2.3
#### delete_existing
Whether to delete any existing tags or releases that match tag if they exist. Default is false, enable with:
`delete_existing: true`

#### release
Whether to create a coresponding release that matches tag

#### release_description
The description text used for the release - format with markdown

#### release_auto_notes
Whether to use the github API to auto generate the release which will be appended to `release_description`. Default is false, enable with:
`release_auto_notes: true`

## Why there is no SHA input paramater

Expand Down
18 changes: 13 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
type: string
required: false
default: ''
release_auto_notes:
type: boolean
required: false
default: false

runs:
using: composite
Expand Down Expand Up @@ -118,6 +122,7 @@ runs:
env:
TAG: ${{ inputs.tag }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
run: |
# Create new tag via GitHub API
# https://docs.github.com/en/rest/reference/git#create-a-reference
Expand All @@ -127,7 +132,7 @@ runs:
-H "Authorization: token ${{ github.token }}" \
-d @- << EOF
{
"sha": "${{ github.sha }}",
"sha": "$GITHUB_SHA",
"ref": "refs/tags/$TAG"
}
EOF
Expand All @@ -145,23 +150,26 @@ runs:
TAG: ${{ inputs.tag }}
RELEASE_DESCRIPTION: ${{ inputs.release_description }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
run: |
# Create new release via GitHub API
# https://docs.github.com/en/rest/releases/releases#create-a-release
# Escape double quotes '"' => '\"'
RELEASE_DESCRIPTION=${RELEASE_DESCRIPTION//\"/\\\"}
# Create new release via GitHub API
# https://docs.github.com/en/rest/releases/releases#create-a-release
RESP_CODE=$(curl -w %{http_code} -s -o /dev/null \
-X POST https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ github.token }}" \
-d @- << EOF
{
"tag_name": "$TAG",
"target_commitish": "${{ github.sha }}",
"target_commitish": "$GITHUB_SHA",
"name": "$TAG",
"body": "$RELEASE_DESCRIPTION",
"draft": false,
"prerelease": false
"prerelease": false,
"generate_release_notes": ${{ inputs.release_auto_notes }},
"make_latest": "legacy"
}
EOF
)
Expand Down

0 comments on commit 2960d8c

Please sign in to comment.