Skip to content

Commit

Permalink
Add release archive workflow (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrobmattrob authored Dec 23, 2023
1 parent 8b3d75e commit 6bd3fd0
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
# 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 }}
22 changes: 22 additions & 0 deletions .github/workflows/generate_release_notes.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
### Bzlmod Snippet
\`\`\`bzl
bazel_dep(name = "swift_bep_parser", version = "$new_version")
\`\`\`
EOF

0 comments on commit 6bd3fd0

Please sign in to comment.