How does one access release artifacts from within a on: release action?

I’d like to write an action that can be triggered on release to grab a release artifact to publish elsewhere. Specifically, how can I access something like github.where.to.get.file.named.foo-1.2.3.zip in this example?

on:
  release:
    types: [published]
jobs:
  publish:
    name: Publish Artifact to PGXN
    runs-on: ubuntu-latest
    container:
      image: something-with-curl
      env:
        PGXN_USERNAME: ${{ secrets.PGXN_USERNAME }}
        PGXN_USERNAME: ${{ secrets.PGXN_PASSWORD }}
        ZIPFILE: ${{ github.where.to.get.file.named.foo-1.2.3.zip }}
    steps:
      run: "curl -O ${ZIPFILE}"
      run: "curl --user \"${PGXN_USERNAME}:${PGXN_PASSWORD}\" -F \"archive=@${ZIPFILE}\" https://manager.pgxn.org/upload)

Thanks!

Hi @theory,

Do you mean to get the code zip from the release? Please use rest api here to get the repository archive.

Code sample as below:

      - name: download zipball to runner
        run: |
          curl -L ${{ github.event.release.zipball_url }} > test.zip  # get the zip file url from github context

Then you can publish the zip file.

Thanks.

curl -L ${{ github.event.release.zipball_url }} > test.zip 

Oh, that makes sense, at least for the zip archive generated by GitHub. I was asking more specifically about files one has uploaded to a release, since sometimes more work is done to make a release download file than the raw contents of the repository.

For this release, for example, I’d like to get the link for semver-0.30.0.zip.

Thanks!

Hi @theory,

Thanks for your reply!

The zip file is in the release assets, it’s supported to get it with the assets id, please check the rest api here for the detail.

Hence, if you’d like to get the asset via filename, you can find the related assets id. Sample code here:

Or you can directly use existing actions to download the assets:

      - uses: wyozi/download-gh-release-asset@master
        with:
          args: semver-0.30.0.zip
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Thanks.

Ah, perfect, just what I was looking for, thank you! Quick question: Is .release.assets a file that’s available to on: release scripts, or is that action downloading it from somewhere?

Hi @theory,

It’s the full event webhook payload(event.json) on the runner, you can check with below command for the content.

cat $GITHUB_EVENT_PATH

More details please check context doc (definition for ‘github.event_path’ ) here.
My workflow for your reference.

Thanks.