Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BuildAndRelease job runs if push to main or a tag is created #805

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,62 @@
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python

#Trigger on pull requests from main
pr:
- main

# Trigger pipeline on push to main or tag creation
trigger:
branches:
include:
- main
- refs/tags/*

# Trigger pipeline on pull request, but only for testing (no release)
pr:
branches:
include:
- main

variables:
CIBW_SKIP: 'cp27-* cp35-*'

jobs:
- job: Testing
pool:
vmImage: 'ubuntu-latest'

steps:
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH

- script: |
python -m pip install --upgrade pip
pip install .
displayName: 'Create Conda environment for DeepForest'
displayName: 'Install Dependencies'

- script: |
pip install pytest tensorboard pytest-azurepipelines yapf
pytest -v
displayName: 'Pytests'
displayName: 'Run Pytests'

# Build and Release job
- job: BuildAndRelease
pool:
vmImage: 'ubuntu-latest'

# Only run this job if the build is triggered by a valid release tag (e.g., 1.4.0, 1.4.1)
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['Build.SourceBranch'], 'refs/tags/$(Build.SourceBranchName)'), not(contains(variables['Build.SourceBranchName'], '-')))

steps:
- bash: |
python3 setup.py sdist bdist_wheel

displayName: 'Build source and wheel distribution'

- task: PublishBuildArtifacts@1
inputs: {pathtoPublish: 'dist'}
displayName: 'Source distribution'
inputs:
pathtoPublish: 'dist'
displayName: 'Publish Source Distribution'

# Optionally publish to PyPI if required, only on tagged releases
- script: |
python -m pip install --upgrade twine
twine upload dist/*
displayName: 'Publish to PyPI'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
Loading