Skip to content

Commit

Permalink
Add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahAndrews committed Apr 25, 2023
1 parent f5a2edf commit 0a0a90f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Create release

on:
push:
tags:
- 'v*'

defaults:
run:
shell: bash

jobs:
check-versions:
runs-on: ubuntu-latest
outputs:
TAG_NAME: ${{ env.TAG_NAME }}
VERSION: ${{ steps.get_version.outputs.version }}
steps:
- name: Get tag name
run: |
echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# Download artifacts from build workflow
- name: Download workflow artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
commit: ${{ github.sha }}
path: '.'

# Get publish.gradle version
- name: Get publish.gradle version
id: get_version
run: |
echo "version=$(cat version/version.txt)" >> $GITHUB_OUTPUT
echo "expectedTagName=v$(cat version/version.txt)" >> $GITHUB_OUTPUT
# Check publish.gradle version
- name: publish.gradle version check FAILED
if: ${{ steps.get_version.outputs.expectedTagName != env.TAG_NAME }}
run: |
echo Tag name: ${{ env.TAG_NAME }}
echo publish.gradle version: ${{ steps.get_version.outputs.version }}
exit 1
prepare-release:
runs-on: ubuntu-latest
needs: check-versions
steps:
# Download API, docs, and version.txt
- name: Download workflow artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
commit: ${{ github.sha }}
path: './artifacts'

# Create new release draft
- name: Create release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ needs.check-versions.outputs.version }}
TAG=v$VERSION
gh release create $TAG --draft --title "Version $VERSION"
echo "Sleep after creating release to avoid race condition"
sleep 5
gh release upload $TAG CANBridge-${{ github.sha }}/*
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ cannot run the tests because they depend on having a USB CAN device connected.

1. Bump the version number in `publish.gradle` and `CANBridge.json`
2. Commit the version bump
3. Create a new tag at that commit
3. Create a new tag named `vX.X.X` at that commit
4. Push the tag to GitHub
5. Wait for the draft release to be created
6. Add release notes to the draft release
7. Publish the draft release

## Changelog

Expand Down

0 comments on commit 0a0a90f

Please sign in to comment.