From 6bd3fd0a20c1356c7fffe040ef1feda19a91a55f Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Sat, 23 Dec 2023 12:45:36 -0700 Subject: [PATCH] Add release archive workflow (#10) Copied off of https://github.com/bazel-ios/rules_ios/blob/master/.github/workflows/create_release.yml Signed-off-by: Matt Robinson --- .github/workflows/create_release.yml | 46 +++++++++++++++++++++ .github/workflows/generate_release_notes.sh | 22 ++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/create_release.yml create mode 100644 .github/workflows/generate_release_notes.sh diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 0000000..6187af8 --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,46 @@ +name: Create Release + +on: + workflow_dispatch: + inputs: + tag: + description: 'The new version to tag, ex: x.x.x' + required: true + type: string + +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create Release + run: | + set -euo pipefail + + git config user.name "Release Workflow" + git config user.email "noreply@github.com" + + # Archive the repository + COPYFILE_DISABLE=1 tar czvf "swift-bep-parser.$TAG.tar.gz" \ + --exclude="./bazel-*" \ + --exclude="user.bazelrc" \ + --exclude=".DS_Store" \ + --exclude="*.xcodeproj" \ + --exclude="Tests/" \ + --exclude="README.md" \ + ./* + + # Create the release notes + ./.github/workflows/generate_release_notes.sh "$TAG" | tee notes.md + + # Create the release + gh release create "$TAG" \ + --title "$TAG" \ + --target "$GITHUB_REF_NAME" \ + --generate-notes \ + --notes-file notes.md \ + "rules_ios.$TAG.tar.gz" + env: + TAG: ${{ inputs.tag }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/generate_release_notes.sh b/.github/workflows/generate_release_notes.sh new file mode 100644 index 0000000..06eea07 --- /dev/null +++ b/.github/workflows/generate_release_notes.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -exuo pipefail + +# This script generates release notes for a release. +# It uses the new tag and archive to generate a workspace snippet. +# It is primarily used by the `create_release.yml` workflow. +# Args: +# - The first argument is the new version number. + +readonly new_version=$1 +readonly release_archive="swift-bep-parser.$new_version.tar.gz" + +sha=$(shasum -a 256 "$release_archive" | cut -d " " -f1) + +cat <