Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release workflow #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
68 changes: 68 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: release
run-name: Prepare release

on:
push:
# Run only on full tag release (v1.0.0). Do not run on partial tags like v1 or v1.0
tags: [ "v[0-9]+.[0-9]+.[0-9]+" ]

jobs:
release:
name: Create release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Get major and minor versions
uses: actions-ecosystem/action-regex-match@v2
id: get-major-minor
with:
text: ${{ github.ref_name }}
regex: '^v([0-9]+)\.([0-9]+)\.[0-9]+'
- name: Create release notes
uses: softprops/action-gh-release@v1
with:
name: Read the Docs Actions ${{ github.ref_name }}
draft: true
generate_release_notes: true
- name: Bump major version tag v${{ steps.get-major-minor.outputs.group1 }}
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
try {
await github.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/v${{ steps.get-major-minor.outputs.group1 }}"
})
} catch (e) {
console.log("The v${{ steps.get-major-minor.outputs.group1 }} tag doesn't exist yet: " + e)
}
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/v${{ steps.get-major-minor.outputs.group1 }}",
sha: context.sha
})
- name: Bump minor version tag v${{ steps.get-major-minor.outputs.group1 }}.${{ steps.get-major-minor.outputs.group2 }}
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
try {
await github.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/v${{ steps.get-major-minor.outputs.group1 }}.${{ steps.get-major-minor.outputs.group2 }}"
})
} catch (e) {
console.log("The v${{ steps.get-major-minor.outputs.group1 }}.${{ steps.get-major-minor.outputs.group2 }} tag doesn't exist yet: " + e)
}
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/v${{ steps.get-major-minor.outputs.group1 }}.${{ steps.get-major-minor.outputs.group2 }}",
sha: context.sha
})