Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Support for publishing latest draft release #63

Open
tayyab-educative opened this issue Apr 24, 2020 · 6 comments
Open

Support for publishing latest draft release #63

tayyab-educative opened this issue Apr 24, 2020 · 6 comments

Comments

@tayyab-educative
Copy link

Is it possible to publish the latest draft release with this action?
I use actions/release-drafter which automatically adds my latest changes to a draft. I want to use this action to publish that release draft automatically when the workflow is triggered.

@mzabaluev
Copy link

Another motivation for this is release notifications.
When a release is first created, then assets are uploaded to it, the release notification email lists only the repository source links. It should be possible to upload the assets to a draft release created at an earlier step, then publish the release.

@tayyab-educative
Copy link
Author

If there's anyone else looking to publish a draft release, you could use the Github API.
You can get all your releases, select the draft release, and update it setting the draft property false. This will publish it.

I'm using this with a cloud function that runs on schedule, so it publishes my release at a regular interval.

@mzabaluev
Copy link

@Tayyab-Anwar Thanks, I guess a workflow can use hub for this, no need for specialized actions.

@eine
Copy link

eine commented Jun 5, 2020

@mzabaluev I tried to do something similar with hub, but I found it to be quite limited. In the end, I used a Python script (https://github.com/eine/tip/blob/master/tip.py). It would be possible to do the same in JavaScript/TypeScript, however with Python there is no need to build/package/transpile the sources.

@kmturley
Copy link

Looks like it might be possible using this third-party action:
https://github.com/marketplace/actions/publish-release

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
    - name: Create Draft Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: <tofill>
        release_name: <tofill>
        draft: true
        prerelease: false

    - uses: actions/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }}
        asset_path: ./my-artifact.zip
        asset_name: my-artifact.zip
        asset_content_type: application/zip

    - uses: eregon/publish-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        release_id: ${{ steps.create_release.outputs.id }}

@kmturley
Copy link

And another potential approach here:
https://github.com/actions/virtual-environments/actions/runs/197846688/workflow

name: Update release

on:
  repository_dispatch:
    types: [update-github-release]


jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Update release for ${{ github.event.client_payload.ReleaseBranchName }}
      uses: actions/github-script@v2
      with:
        github-token: ${{secrets.GITHUB_TOKEN}}
        script: |
            const response = await github.repos.getReleaseByTag({
              owner: context.repo.owner,
              repo: context.repo.repo,
              tag: "${{ github.event.client_payload.ReleaseBranchName }}"
            });
            github.repos.updateRelease({
              owner: context.repo.owner,
              repo: context.repo.repo,
              release_id: response.data.id,
              prerelease: ${{ github.event.client_payload.Prerelease }}
            });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants