mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
task: implement release action
This commit is contained in:
parent
02ae984699
commit
201b9b9673
3 changed files with 131 additions and 42 deletions
45
.github/contributing.md
vendored
45
.github/contributing.md
vendored
|
@ -20,42 +20,9 @@
|
|||
## For Release
|
||||
|
||||
- create releases following [semver policy](https://semver.org/)
|
||||
- we are using [gren](https://github.com/github-tools/github-release-notes) to generate the changelog and releases
|
||||
|
||||
### One Time Steps
|
||||
|
||||
- Generate API Token as described in [gren's README.md](https://github.com/github-tools/github-release-notes)
|
||||
- On Windows do `setx GREN_GITHUB_TOKEN <API TOKEN>` and restart your shell
|
||||
|
||||
### Steps per Release
|
||||
|
||||
- close all issues of the milestone or push them back to an open milestone
|
||||
- close the milestone
|
||||
- Tag and push the repo
|
||||
|
||||
```shell
|
||||
git tag --message "" <tag>
|
||||
git push origin <tag>
|
||||
```
|
||||
|
||||
- regenerate changelog with _gren_
|
||||
|
||||
```shell
|
||||
npx github-release-notes@0.17.1 changelog --generate --override --tags=all
|
||||
```
|
||||
|
||||
- add the changelog to git and update the tag
|
||||
|
||||
```shell
|
||||
git add exampleSite/content/basics/CHANGELOG.md
|
||||
git commit --message "Ship tag <tag>"
|
||||
git push origin main
|
||||
git tag --message "" --force <tag>
|
||||
git push --force origin <tag>
|
||||
```
|
||||
|
||||
- generate release with _gren_
|
||||
|
||||
```shell
|
||||
npx github-release-notes@0.17.1 release --tags <tag>
|
||||
```
|
||||
- we are using GitHub actions to create new releases
|
||||
- a release is based on a milestone named like the release itself - just the version number, eg: 1.1.0
|
||||
- remember that there have to be at least one closed issue assigned to the milestone
|
||||
- the release action only runs successfully if all assigned issues for this milestone are closed
|
||||
- the milestone itself will be closed during execution of the action
|
||||
- a once released milestone can not be released again
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: Deploy GitHub Pages
|
||||
name: CI/CD
|
||||
|
||||
on:
|
||||
push: # Build on all pushes but only deploy for main branch
|
||||
|
@ -7,10 +7,10 @@ on:
|
|||
|
||||
jobs:
|
||||
ci:
|
||||
name: Run CI
|
||||
name: Run CI/CD
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout site
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true # Fetch Hugo themes (true OR recursive)
|
122
.github/workflows/release.yaml
vendored
Normal file
122
.github/workflows/release.yaml
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
milestone:
|
||||
description: 'Milestone for this release'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
release_state:
|
||||
name: Get tag and milestone state
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
MILESTONE: ${{ github.event.inputs.milestone }} # To avoid code injection
|
||||
outputs:
|
||||
has_closed_issues: ${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount > 0 }}
|
||||
has_open_issues: ${{ fromJSON(steps.open_issues.outputs.data).search.issueCount > 0 }}
|
||||
has_unique_tag: ${{ steps.unique_tag.outcome == 'failure' }}
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get closed issues for milestone
|
||||
id: closed_issues
|
||||
uses: octokit/graphql-action@v2.x
|
||||
with:
|
||||
query: |
|
||||
query {
|
||||
search(first: 1, type: ISSUE, query: "user:${{ github.repository_owner }} repo:${{ github.event.repository.name }} milestone:${{ env.MILESTONE }} state:closed") {
|
||||
issueCount
|
||||
}
|
||||
}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Get open issues for milestone
|
||||
id: open_issues
|
||||
uses: octokit/graphql-action@v2.x
|
||||
with:
|
||||
query: |
|
||||
query {
|
||||
search(first: 1, type: ISSUE, query: "user:${{ github.repository_owner }} repo:${{ github.event.repository.name }} milestone:${{ env.MILESTONE }} state:open") {
|
||||
issueCount
|
||||
}
|
||||
}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Get tag uniqueness
|
||||
id: unique_tag
|
||||
continue-on-error: true
|
||||
run: git rev-parse "$MILESTONE" --
|
||||
|
||||
release_log:
|
||||
name: Log tag and milestone state
|
||||
needs: release_state
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
MILESTONE: ${{ github.event.inputs.milestone }} # To avoid code injection
|
||||
steps:
|
||||
- run: "echo has unique tag : ${{ needs.release_state.outputs.has_unique_tag }}"
|
||||
- run: "echo has closed issues: ${{ needs.release_state.outputs.has_closed_issues }}"
|
||||
- run: "echo has open issues : ${{ needs.release_state.outputs.has_open_issues }}"
|
||||
|
||||
release:
|
||||
name: Create release
|
||||
needs: release_state
|
||||
if: needs.release_state.outputs.has_closed_issues == 'true' && needs.release_state.outputs.has_open_issues == 'false' && needs.release_state.outputs.has_unique_tag == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
MILESTONE: ${{ github.event.inputs.milestone }} # To avoid code injection
|
||||
GREN_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Setup git env
|
||||
run: |
|
||||
git config user.name "GitHub Actions Bot"
|
||||
git config user.email "<>"
|
||||
|
||||
- name: Close milestone
|
||||
uses: Akkjon/close-milestone@v2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
milestone_name: ${{ env.MILESTONE }}
|
||||
|
||||
- name: Create provisionary tag
|
||||
run: git tag --message "" "$MILESTONE"
|
||||
|
||||
- name: Push provisionary tag
|
||||
run: git push origin "$MILESTONE"
|
||||
|
||||
- name: Update changelog
|
||||
run: npx github-release-notes@0.17.1 changelog --generate --override --tags=all
|
||||
|
||||
- name: Stage changelog
|
||||
run: git add *
|
||||
|
||||
- name: Commit changelog
|
||||
run: git commit --message "Ship tag $MILESTONE"
|
||||
|
||||
- name: Push changelog
|
||||
run: git push origin main
|
||||
|
||||
- name: Create final tag
|
||||
run: git tag --force --message "" "$MILESTONE"
|
||||
|
||||
- name: Push final tag
|
||||
run: git push --force origin "$MILESTONE"
|
||||
|
||||
- name: Publish release
|
||||
run: npx github-release-notes@0.17.1 release --tags "$MILESTONE"
|
Loading…
Reference in a new issue