Skip to content

Create a new release #18

Create a new release

Create a new release #18

Workflow file for this run

#---------------------------------------------------------
# - Create a semantical release
# - Set latest tag
#---------------------------------------------------------
name: Create a new release
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
# required antecedent
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20.9.0'
- name: Install npm dev dependencies
run: npm install --only=dev
- name: Get current version
id: current_version
run: |
echo "::set-output name=version::$(python -c 'from __version__ import __version__; print(__version__)')"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Get next version
id: next_version
run: |
echo "::set-output name=version::$(npx semantic-release --dry-run | awk '/The next release version is/{print $NF}')"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Update __version__
if: steps.current_version.outputs.version != steps.next_version.outputs.version
run: |
echo "__version__ = '${{ steps.next_version.outputs.version }}'" > __version__.py
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add __version__.py
git commit -m "chore: [gh] Update __version__.py to ${{ steps.next_version.outputs.version }} [skip ci]"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:main
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
'next-major',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
]
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
- name: Publish To GitHub Package Registry
if: steps.semantic.outputs.new_release_published == 'true'
run: echo "new release was published"
shell: bash
- name: Push updates to branch for major version
if: steps.semantic.outputs.new_release_published == 'true'
run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/v${{steps.semantic.outputs.new_release_major_version}}"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}