diff --git a/.azure-pipelines/publish.yml b/.azure-pipelines/publish.yml deleted file mode 100644 index 035d621..0000000 --- a/.azure-pipelines/publish.yml +++ /dev/null @@ -1,103 +0,0 @@ -pr: none - -trigger: - tags: - include: - - '*' - -resources: - repositories: - - repository: 1esPipelines - type: git - name: 1ESPipelineTemplates/1ESPipelineTemplates - ref: refs/tags/release - -extends: - template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines - parameters: - pool: - name: DevDivPlaywrightAzurePipelinesUbuntu2204 - os: linux - sdl: - sourceAnalysisPool: - name: DevDivPlaywrightAzurePipelinesWindows2022 - # The image must be windows-based due to restrictions of the SDL tools. See: https://aka.ms/AAo6v8e - # In the case of a windows build, this can be the same as the above pool image. - os: windows - stages: - - stage: Stage - jobs: - - job: Build - templateContext: - outputs: - - output: pipelineArtifact - path: $(Build.ArtifactStagingDirectory)/esrp-build - artifact: esrp-build - steps: - - checkout: self - persistCredentials: false - displayName: "Checkout code" - - - bash: | - if [[ ! "$CURRENT_BRANCH" =~ ^v[0-9]+\..* ]]; then - echo "Can only publish from a release tag (v*)." - echo "Unexpected ref name: $CURRENT_BRANCH" - exit 1 - fi - env: - CURRENT_BRANCH: ${{ variables['Build.SourceBranchName'] }} - displayName: 'Check the ref is a release tag' - # Allow manual runs on any branch to exercise the build without publishing. - condition: ne(variables['Build.Reason'], 'Manual') - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.10' - displayName: 'Use Python' - # Resolve every pip install (including the isolated build environments - # that `python -m build` creates) through the DevDiv_PublicPackages Azure - # Artifacts feed instead of pypi.org, as required by SFI-ES4.2.4. The - # task exports an authenticated PIP_INDEX_URL. - - task: PipAuthenticate@1 - inputs: - artifactFeeds: DevDiv/DevDiv_PublicPackages - displayName: 'Authenticate pip to DevDiv_PublicPackages feed' - - script: | - python -m pip install --upgrade pip --disable-pip-version-check - pip install -r local-requirements.txt --disable-pip-version-check - python -m build --outdir $(Build.ArtifactStagingDirectory)/esrp-build pytest-playwright - python -m build --outdir $(Build.ArtifactStagingDirectory)/esrp-build pytest-playwright-asyncio - displayName: 'Install & Build' - - job: Publish - dependsOn: Build - # Only publish from release tags; manual runs on a branch stop after Build, - # which lets the build be exercised without publishing. - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) - templateContext: - type: releaseJob - isProduction: true - inputs: - - input: pipelineArtifact - artifactName: esrp-build - targetPath: $(Build.ArtifactStagingDirectory)/esrp-build - steps: - - checkout: none - - task: EsrpRelease@11 - inputs: - connectedservicename: 'Playwright-ESRP-PME' - usemanagedidentity: true - keyvaultname: 'playwright-esrp-pme' - signcertname: 'ESRP-Release-Sign' - clientid: '13434a40-7de4-4c23-81a3-d843dc81c2c5' - intent: 'PackageDistribution' - contenttype: 'PyPi' - # Keeping it commented out as a workaround for: - # https://portal.microsofticm.com/imp/v3/incidents/incident/499972482/summary - # contentsource: 'folder' - folderlocation: '$(Build.ArtifactStagingDirectory)/esrp-build' - waitforreleasecompletion: true - owners: 'dgozman@microsoft.com' - approvers: 'dgozman@microsoft.com' - serviceendpointurl: 'https://api.esrp.microsoft.com' - mainpublisher: 'Playwright' - domaintenantid: '975f013f-7f24-47e8-a7d3-abc4752bf346' - displayName: 'ESRP Release to PIP' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..187a60a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,77 @@ +name: Publish + +# Builds pytest-playwright and pytest-playwright-asyncio from a release tag and +# uploads them to PyPI. Uses PyPI trusted publishing: PyPI trusts this workflow +# file in the "pypi" environment, so no PyPI token is stored. Runs when a release +# is published. To publish an existing tag, run it by hand with the tag name. +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: "Release tag to publish, for example v0.10.0" + required: true + +permissions: + contents: read + +jobs: + build: + name: Build packages + runs-on: ubuntu-latest + env: + TAG: ${{ inputs.tag || github.event.release.tag_name }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: refs/tags/${{ env.TAG }} + # setuptools-scm reads the version from the tag. + fetch-depth: 0 + - name: Check the tag + run: | + if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Can only publish a release tag (vX.Y.Z), got: $TAG" + exit 1 + fi + - name: Set up Python + uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: "3.10" + - name: Install dependencies + run: python -m pip install "$(grep '^build==' local-requirements.txt)" + - name: Build the wheels and the sdists + run: | + python -m build --outdir dist pytest-playwright + python -m build --outdir dist pytest-playwright-asyncio + - name: Check the wheels and the sdists + run: | + ls -l dist + version="${TAG#v}" + for name in pytest_playwright pytest_playwright_asyncio; do + test -f "dist/$name-$version-py3-none-any.whl" + test -f "dist/$name-$version.tar.gz" + done + test "$(ls dist | wc -l)" -eq 4 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: packages + path: dist/ + if-no-files-found: error + + publish: + name: Upload to PyPI + needs: build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/pytest-playwright/ + permissions: + # Lets the job get the GitHub OIDC token that PyPI trusted publishing needs. + id-token: write + steps: + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: packages + path: dist/ + - uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3