Skip to content

🔧 Separate CI of testing from Release one #30

🔧 Separate CI of testing from Release one

🔧 Separate CI of testing from Release one #30

Workflow file for this run

name: Versioning and Release
on:
push:
branches:
- main
pull_request: {}
jobs:
retrieve-version:
name: Retrieve Version
runs-on: ubuntu-latest
outputs:
authx-version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Get version from __init__.py
id: get_version
shell: python
run: |
import re
from typing import Optional
def get_version(file_path: str = 'authx/__init__.py') -> Optional[str]:
version_pattern = r'__version__\s*=\s*"(?P<version>[\d\.]+)"'
try:
with open(file_path, 'r') as file:
content = file.read()
if match := re.search(version_pattern, content):
return match['version']
except FileNotFoundError:
print(f"File {file_path} not found.")
return None
print(get_version())
- name: Save version to output
run: echo "authx-version=${{ steps.get_version.outputs.version }}" >> $GITHUB_ENV
send-tweet:
name: Send Tweet
needs: retrieve-version
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# - name: Install dependencies
# run: pip install tweepy==4.14.0
- name: Send tweet
shell: python
run: |
# TODO: Test this code
import os
version = os.getenv("VERSION").strip('"')
print(f"Authx version {version} is out! 🎉")
env:
VERSION: ${{ needs.retrieve-version.outputs.authx-version }}
# TWEET: |
# Authx version {version} is out! 🎉
# https://github.com/yezz123/authx/releases/tag/{version}
# TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
# TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
# TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
# TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}