Open tayyab-educative opened 4 years ago
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.
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.
@tayyab-anwar Thanks, I guess a workflow can use hub
for this, no need for specialized actions.
@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.
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/upload-release-asset@v1.0.1
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 }}
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 }}
});
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.