Skip to content

Commit

Permalink
auto release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
i.o.novikov committed Feb 22, 2022
1 parent a2dc1ac commit a8e56bb
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/resuable-workflow-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "Release workflows"
on:
push:
branches:
- "main"

jobs:
Create-release-with-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
with:
semver_only: true
initial_version: 'v1.0.0'

- uses: actions-ecosystem/action-bump-semver@v1
id: bump-semver
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: patch

- uses: actions-ecosystem/action-push-tag@v1
with:
tag: ${{ steps.bump-semver.outputs.new_version }}
message: '${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}'
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.bump-semver.outputs.new_version }}
release_name: Release ${{ steps.bump-semver.outputs.new_version }}
draft: false
prerelease: false

- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ steps.bump-semver.outputs.new_version }}
regex: '^v(\d+).'

- name: Move major tag
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.regex-match.outputs.group1 }}"
})
} catch (e) {
console.log("The nightly tag doesn't exist yet: " + e)
}
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/v${{ steps.regex-match.outputs.group1 }}",
sha: context.sha
})

0 comments on commit a8e56bb

Please sign in to comment.