Skip to content

Commit

Permalink
chore(release): add automated release workflow (#2)
Browse files Browse the repository at this point in the history
* chore(release): add automated release workflow

Adds a workflow file which can be run to create a semantic
tag and immediately afterwards, create a release on GitHub.

Any collaborator with write access should be able to
trigger the workflow.

This commit also adds another workflow file, which leaves a
comment after a PR has been merged. The comment reminds to
trigger the aforementioned release workflow.

* chore: delete pr commenter

* chore: fix naming and specify defaults

* chore: skip release if release exists

* chore: release if tag is provided to the step properly

* chore: default bump is patch if no input tag

* chore: attach files to GitHub release

Per feedback: #2 (comment)

* chore: remove . directory from the archive

* chore: make sure to pass down the archive file name
  • Loading branch information
rebornplusplus authored Jul 11, 2023
1 parent e92d18b commit 1b54b35
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Tag and Release

on:
workflow_dispatch:
inputs:
tag:
description: "Tag (Optional, without 'v' e.g. 1.2.3)"
required: false

jobs:
release:
name: Tag and release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: ${{ inputs.tag == '' && 'patch' || false }}
custom_tag: ${{ inputs.tag }}

- name: Prepare archive
id: prep_archive
env:
TAG: ${{ steps.tag_version.outputs.new_tag }}
run: |
ARCHIVE_FILE=rocks-toolbox_${TAG}.tar.gz
echo "Creating archive $ARCHIVE_FILE"
dir=dist/${TAG}
mkdir -p $dir
cp chisel-wrapper $dir
cp LICENSE README.md $dir
find $dir -printf "%P\n" | tar -czf dist/$ARCHIVE_FILE --no-recursion -C $dir -T -
echo "ARCHIVE_FILE=${ARCHIVE_FILE}" >>$GITHUB_OUTPUT
- name: Create GitHub release
uses: ncipollo/release-action@v1.12.0
if: startsWith(${{ steps.tag_version.outputs.new_tag }}, 'v')
with:
name: ${{ steps.tag_version.outputs.new_tag }}
tag: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
generateReleaseNotes: true
skipIfReleaseExists: true
artifacts: dist/${{ steps.prep_archive.outputs.ARCHIVE_FILE }}

0 comments on commit 1b54b35

Please sign in to comment.