Skip to content

/app/twine-upload.sh: line 45: GITHUB_WORKFLOW_REF: unbound variable #275

Closed
@WilliamStam

Description

@WilliamStam

using this action with gitea tho. everything was working great and then suddenly it stopped.

ive tried manually pushing to gitea's pypi repo and it works fine. but whenever i try publish using this action it errors out with

image

im including the full workflow action here. (it includes non relevant stuff sorry)

name: Build And Test
run-name: ${{ gitea.actor }} is running PyPI build and push
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    container: catthehacker/ubuntu:act-latest
    environment: release
    permissions:
      id-token: write
    steps:
      - name: Info
        run: |
          echo "Trigger: ${{ gitea.event_name }} "
          echo "OS: ${{ runner.os }}"
          echo "Branch: ${{ gitea.ref }}"
          echo "Repository: ${{ gitea.server_url }}/${{ gitea.repository }}.git"
          echo "Workspace: ${{ gitea.workspace }}"
          echo "-----------"
          echo "${{ toJSON(gitea) }}"
          

      - name: Checkout Codebase
        uses: actions/checkout@v3

      - name: Setup Python
        run: |
          apt-get update && apt-get install -y python3-venv
          pip install --upgrade pdm

      - name: Setup PDM
        uses: pdm-project/setup-pdm@v3
        with:
          python-version-file: 'pyproject.toml'

      - name: Install Dependencies
        run: cd ${{ gitea.workspace }} && pdm install

      - name: Get Meta
        id: meta
        run: |
          echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
          echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT      
          echo PACKAGE_VERSION=$(pdm show --version) >> $GITHUB_OUTPUT      
          echo PACKAGE_NAME=$(pdm show --name) >> $GITHUB_OUTPUT           

      - name: Build
        run: cd ${{ gitea.workspace }} && pdm build

      - name: Publish release
        uses: akkuman/gitea-release-action@v1
        with:
          files: |-
            ./dist/**
          name: '${{ steps.meta.outputs.PACKAGE_VERSION }}'
          tag_name: '${{ steps.meta.outputs.PACKAGE_VERSION }}'

      - name: "Publish dists to PyPI"
        uses: "pypa/gh-action-pypi-publish@release/v1"
        with:
          verbose: true
          skip-existing: true
          repository-url: ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/pypi
          user: ${{ secrets.PYPI_USER }}
          password: ${{ secrets.PYPI_PASSWORD }}

line 45 of twine-upload.sh

WORKFLOW_FILENAME="$(echo ${GITHUB_WORKFLOW_REF} | cut -d'/' -f5- | cut -d'@' -f1)"

which only gets used in the "else"

if [[ "${TRUSTED_PUBLISHING}" == true || ! "${INPUT_REPOSITORY_URL}" =~ pypi\.org || ${#PACKAGE_NAMES[@]} -eq 0 ]] ; then
    TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE=""
else
    ...
    for PACKAGE_NAME in "${PACKAGE_NAMES[@]}"; do
        LINK="- ${INDEX_URL}/manage/project/${PACKAGE_NAME}/settings/publishing/?provider=github&owner=${GITHUB_REPOSITORY_OWNER}&repository=${REPOSITORY_NAME}&workflow_filename=${WORKFLOW_FILENAME}"
        ALL_LINKS+="$LINK"$'\n'
    done

where does the issue lie here? my thinking is that gitea isnt setting the GITHUB_WORKFLOW_REF env in the action runner. but is it something that gitea should even be concerned with? shouldnt this action check if it exists and if so use it else ignore?

(gitea 1.22.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions