gh-action-pypi-publish/.github/workflows/publish-major-minor.yml

52 lines
1.9 KiB
YAML
Raw Normal View History

2020-11-03 22:55:55 +08:00
name: "Publish Major-Minor-Tags"
on:
push:
tags:
- "v*"
jobs:
push-tags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install packaging
2020-11-04 07:34:14 +08:00
run: python -m pip install -U packaging --user
2020-11-03 22:55:55 +08:00
- name: Get versions
id: get_versions
2020-11-04 07:23:22 +08:00
shell: python
run: |
from packaging.version import parse
2020-11-04 07:34:14 +08:00
2020-11-04 07:23:22 +08:00
tag_ref = "${{ github.ref }}"
tag_name = tag_ref.split("/")[-1]
version = parse(tag_name)
2020-11-04 07:34:14 +08:00
print(f"tag_name: {tag_name}")
2020-11-04 07:23:22 +08:00
print(f"version: {version}")
2020-11-04 07:34:14 +08:00
if not version.is_prerelease:
2020-11-04 07:23:22 +08:00
print("Creating new major and minor tags!")
print(f"::set-output name=original_tag_name::{tag_name}")
print(f"::set-output name=major_version::v{version.major}")
print(f"::set-output name=minor_version::v{version.major}.{version.minor}")
else:
print("No tags created (dev or pre version)!")
2020-11-03 22:55:55 +08:00
- name: Push Tags Version
if: steps.get_versions.outputs.original_tag_name != ''
env:
original_tag_name: ${{ steps.get_versions.outputs.original_tag_name }}
major_version: ${{ steps.get_versions.outputs.major_version }}
minor_version: ${{ steps.get_versions.outputs.minor_version }}
run: |
2020-11-04 07:34:14 +08:00
git config user.email 'github-actions[bot]@users.noreply.github.com'
git config user.name 'github-actions[bot]'
git tag --annotate '${{ env.major_version }}' \
--message='original tag: ${{ env.original_tag_name }}'
git tag --annotate '${{ env.minor_version }}' \
--message='original tag: ${{ env.original_tag_name }}'
git push origin '${{ env.major_version }}' --force-with-lease
git push origin '${{ env.minor_version }}' --force-with-lease