remove non existant argument #57
Workflow file for this run
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
on: | |
push: | |
pull_request: | |
branches: | |
# Branches from forks have the form 'user:branch-name' so we only run | |
# this job on pull_request events for branches that look like fork | |
# branches. Without this we would end up running this job twice for non | |
# forked PRs, once for the push and then once for opening the PR. | |
- '**:**' | |
jobs: | |
# Build the package | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install poetry | |
uses: Gr1N/setup-poetry@v8 | |
- name: Build package | |
run: poetry build | |
- name: Save built package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
retention-days: 1 | |
# Run pytest using built package | |
test: | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: ["3.9", "3.10", "3.11"] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: 'pip' | |
cache-dependency-path: "poetry.lock" | |
- name: Download built package | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
- name: Install package and pytest | |
shell: bash | |
run: | | |
WHL_NAME=$(ls molecule_resolver-*.whl) | |
pip install ${WHL_NAME} pytest | |
- name: Run tests | |
shell: bash | |
run: pytest | |
# Tag and release the package | |
release: | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Download built package | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
- name: Determine the version for this release from the build | |
id: current | |
run: | | |
BUILD_VER="$(ls dist/molecule_resolver-*.tar.gz)" | |
echo "Path: $BUILD_VER" | |
if [[ $BUILD_VER =~ (molecule_resolver-)([^,][0-9.]{4}) ]]; then | |
echo "version=${BASH_REMATCH[2]}" >> $GITHUB_OUTPUT | |
echo "Version of build: ${BASH_REMATCH[2]}" | |
else | |
echo "No version found found" | |
fi | |
- name: Install coveo-pypi-cli | |
run: pip install coveo-pypi-cli | |
- name: Get latest published version | |
id: published | |
run: | | |
PUB_VER="$(pypi current-version molecule-resolver)" | |
echo "version=$PUB_VER" >> $GITHUB_OUTPUT | |
echo "Latest published version: $PUB_VER" | |
- name: Tag repository | |
shell: bash | |
id: get-next-tag | |
if: (steps.current.outputs.version != steps.published.outputs.version) | |
run: | | |
TAG_NAME=${{ steps.current.outputs.version }} | |
echo "tag-name=$TAG_NAME" >> $GITHUB_OUTPUT | |
echo "This release will be tagged as $TAG_NAME" | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git tag --annotate --message="Automated tagging system" $TAG_NAME ${{ github.sha }} | |
- name: Push the tag | |
if: (steps.current.outputs.version != steps.published.outputs.version) | |
id: push_tag | |
env: | |
TAG_NAME: ${{ steps.current.outputs.version }} | |
run: | | |
if [[ ${{ github.ref_name }} == 'main' ]]; then | |
git push origin $TAG_NAME | |
echo "should_release=true" >> $GITHUB_OUTPUT | |
else | |
echo "If this was the main branch, I would push a new tag named $TAG_NAME" | |
echo "should_release=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: ${{ steps.push_tag.outputs.should_release == 'true' }} | |
with: | |
files: dist/molecule_resolver-${{ steps.current.outputs.version }}.tar.gz | |
outputs: | |
publish_pypi: steps.push_tag.outputs.should_release | |
publish_test_pypi: ${{ (steps.current.outputs.version != steps.published.outputs.version) && github.ref_name != 'main' }} | |
# Publish the package to pypi | |
publish: | |
needs: release | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- name: Download built package | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
- name: Publish to pypi if new version | |
env: | |
should_publish: ${{ needs.release.outputs.publish_pypi }} | |
if: ${{ env.should_publish == 'true' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: dist/ | |
- name: Publish to test pypi if new version not on main | |
env: | |
should_publish: ${{ needs.release.outputs.publish_test_pypi }} | |
if: ${{ env.should_publish == 'true' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: dist/ | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true |