This GitHub Action (written in TypeScript) uses the GitHub Release API, specifically the Update a Release endpoint, to set draft=false
on an existing release.
This action is similar to eregon/publish-release
, but additionally has support for releases on repos other than the one from which it is run.
Create a workflow .yml
file in your .github/workflows
directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file.
For more information on these inputs, see the API Documentation
id
: The release id, e.g. from theid
output of theactions/create-release
GitHub Action.owner
: The name of the owner of the repo. Used to identify the owner of the repository. Used when cutting releases for external repositories. Default: Current ownerrepo
: The name of the repository. Used to identify the repository on which to release. Used when cutting releases for external repositories. Default: Current repository
The GITHUB_TOKEN
environment variable must be set to an appropriate access token. If publishing on the same repo that runs the workflow, the automatically created token ${{ secrets.GITHUB_TOKEN }}
should work. If the release is on a different repo, you need to create a personal access token with write privileges on the target repo and store it as a secret.
- Create a draft release
- Upload an attachment
- Publish the draft release
On every push
to a tag matching the pattern v*
, create a release:
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release
- First Change
- Second Change
draft: true
prerelease: false
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./path/to/asset.zip
asset_name: asset.zip
asset_content_type: application/zip
- name: Publish release
uses: StuYarrow/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
id: ${{ steps.create_release.outputs.id }}
The scripts and documentation in this project are released under the MIT License