From 0a0a90f9e677f79d7dbaf70cba85f47e227a33d9 Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 18:29:08 -0500 Subject: [PATCH] Add release workflow --- .github/workflows/release.yml | 71 +++++++++++++++++++++++++++++++++++ README.md | 5 ++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9a90457 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }}/* diff --git a/README.md b/README.md index 92f6d09..1cd7558 100644 --- a/README.md +++ b/README.md @@ -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