test: update test for ci/cd 3 #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#name: Tag Release | |
# | |
#on: | |
# push: | |
# branches: | |
# - master | |
# | |
#jobs: | |
# tag: | |
# runs-on: ubuntu-latest | |
# | |
# steps: | |
# - name: Checkout code | |
# uses: actions/checkout@v3 | |
# | |
# - name: Get latest tag | |
# id: get_latest_tag | |
# run: | | |
# git fetch --tags | |
# TAG=$(git tag --sort=-creatordate | head -n 1) | |
# echo "Latest tag is $TAG" | |
# echo "::set-output name=latest::$TAG" | |
# | |
# - name: Determine new version | |
# id: new_version | |
# run: | | |
# latest_tag="${{ steps.get_latest_tag.outputs.latest }}" | |
# if [ -z "$latest_tag" ]; then | |
# new_version="v0.1.0" | |
# else | |
# # Increment the patch version | |
# new_version=$(echo $latest_tag | awk -F. -v OFS=. '{$NF++;print}') | |
# fi | |
# echo "New version is $new_version" | |
# echo "::set-output name=new_version::$new_version" | |
# | |
# - name: Create new tag | |
# run: | | |
# git tag "${{ steps.new_version.outputs.new_version }}" | |
# git push origin "${{ steps.new_version.outputs.new_version }}" | |
name: Release and Publish | |
on: | |
push: | |
branches: | |
- master # Adjust as necessary | |
release: | |
types: [published] # Trigger on release published | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get latest tag | |
id: get_latest_tag | |
run: | | |
git fetch --tags | |
TAG=$(git tag --sort=-creatordate | head -n 1) | |
echo "Latest tag is $TAG" | |
echo "::set-output name=latest::$TAG" | |
- name: Determine new version | |
id: new_version | |
run: | | |
latest_tag="${{ steps.get_latest_tag.outputs.latest }}" | |
if [ -z "$latest_tag" ]; then | |
new_version="v0.1.0" | |
else | |
# Increment the patch version | |
new_version=$(echo $latest_tag | awk -F. -v OFS=. '{$NF++;print}') | |
fi | |
echo "New version is $new_version" | |
echo "::set-output name=new_version::$new_version" | |
- name: Create new tag | |
run: | | |
git tag "${{ steps.new_version.outputs.new_version }}" | |
git push origin "${{ steps.new_version.outputs.new_version }}" | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Set PYTHONPATH | |
run: echo "PYTHONPATH=$(pwd)/torchebm" >> $GITHUB_ENV | |
- name: Install package | |
run: | | |
pip install . | |
- name: Set PYTHONPATH | |
run: echo "PYTHONPATH=$(pwd)/torchebm" >> $GITHUB_ENV | |
- name: Install package | |
run: | | |
pip install . | |
- name: Run tests | |
run: | | |
pytest tests/ # Adjust the path to your test directory | |
- name: Build the package | |
run: | | |
python -m pip install --upgrade build | |
python -m build # This will create .tar.gz and .whl files in the dist/ directory | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
username: __token__ # Use __token__ for token-based authentication | |
password: ${{ secrets.PYPI_API_TOKEN_EBM }} |