Skip to content

Commit ce68eb4

Browse files
committed
ci: refactor
1 parent 6b3abbe commit ce68eb4

File tree

3 files changed

+51
-74
lines changed

3 files changed

+51
-74
lines changed
Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
name: Package and Release Tarot Deck
1+
name: Package and Release Tarot Decks
22

33
permissions:
44
contents: write
55

66
on:
77
workflow_dispatch:
8+
inputs:
9+
deck_name:
10+
description: 'Deck to package (e.g., rider-waite-smith)'
11+
required: true
12+
default: 'rider-waite-smith'
813
push:
914
branches:
1015
- main
1116
tags:
12-
- 'v*'
17+
- '*/*' # Matches tags like rider-waite-smith/v1.0
1318

1419
jobs:
1520
build-and-release:
@@ -18,34 +23,72 @@ jobs:
1823
- name: Checkout code
1924
uses: actions/checkout@v3
2025

26+
- name: Set deck name
27+
id: deck
28+
run: |
29+
# Use input deck name for manual triggers, otherwise default to rider-waite-smith
30+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
31+
DECK_NAME="${{ github.event.inputs.deck_name }}"
32+
else
33+
# For tag pushes, extract deck name from tag (e.g., rider-waite-smith/v1.0 -> rider-waite-smith)
34+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
35+
TAG_NAME="${{ github.ref_name }}"
36+
DECK_NAME=$(echo $TAG_NAME | cut -d'/' -f1)
37+
else
38+
# Default to rider-waite-smith for branch pushes
39+
DECK_NAME="rider-waite-smith"
40+
fi
41+
fi
42+
43+
echo "Using deck: $DECK_NAME"
44+
echo "deck_name=$DECK_NAME" >> $GITHUB_OUTPUT
45+
2146
- name: Extract version and package deck
2247
id: package
2348
run: |
24-
VERSION=$(grep -E '^version\s*=\s*"[^"]+"' rider-waite-smith/deck.toml | sed -E 's/^version\s*=\s*"([^"]+)"/\1/')
49+
DECK_NAME="${{ steps.deck.outputs.deck_name }}"
50+
51+
# Make sure the deck directory exists
52+
if [ ! -d "$DECK_NAME" ]; then
53+
echo "Error: Deck directory '$DECK_NAME' not found!"
54+
exit 1
55+
fi
56+
57+
VERSION=$(grep -E '^version\s*=\s*"[^"]+"' $DECK_NAME/deck.toml | sed -E 's/^version\s*=\s*"([^"]+)"/\1/')
2558
echo "Found version: $VERSION"
2659
27-
PACKAGE_NAME="rider-waite-smith-${VERSION}"
60+
# Extract human-readable name from deck.toml
61+
DISPLAY_NAME=$(grep -E '^name\s*=\s*"[^"]+"' $DECK_NAME/deck.toml | sed -E 's/^name\s*=\s*"([^"]+)"/\1/' || echo "$DECK_NAME")
62+
echo "Display name: $DISPLAY_NAME"
63+
64+
# Create package name
65+
PACKAGE_NAME="${DECK_NAME}-${VERSION}"
2866
ZIP_FILE="${PACKAGE_NAME}.zip"
2967
echo "Creating package: $ZIP_FILE"
3068
31-
zip -r "${ZIP_FILE}" rider-waite-smith
69+
# Create the zip file
70+
zip -r "${ZIP_FILE}" $DECK_NAME
3271
ls -la "${ZIP_FILE}"
3372
73+
# Set output variables
3474
echo "version=$VERSION" >> $GITHUB_OUTPUT
3575
echo "zip_file=$ZIP_FILE" >> $GITHUB_OUTPUT
76+
echo "display_name=$DISPLAY_NAME" >> $GITHUB_OUTPUT
77+
echo "tag_name=${{ steps.deck.outputs.deck_name}}/v${VERSION}" >> $GITHUB_OUTPUT
3678
3779
- name: Create Release
3880
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
3981
uses: softprops/action-gh-release@v2
4082
with:
4183
files: ${{ steps.package.outputs.zip_file }}
42-
name: Rider-Waite-Smith Tarot Deck v${{ steps.package.outputs.version }}
84+
name: ${{ steps.package.outputs.display_name }} v${{ steps.package.outputs.version }}
85+
tag_name: ${{ steps.package.outputs.tag_name }}
4386
draft: false
4487
prerelease: false
4588
body: |
46-
Rider-Waite-Smith Tarot Deck v${{ steps.package.outputs.version }}
89+
# ${{ steps.package.outputs.display_name }} Tarot Deck v${{ steps.package.outputs.version }}
4790
48-
This release contains the packaged Rider-Waite-Smith tarot deck version ${{ steps.package.outputs.version }} according to the Tarot Deck Specification.
91+
This release contains the ${{ steps.package.outputs.display_name }} deck in the format described by the [Tarot Deck Specification](https://github.com/arcanaland/specifications).
4992
env:
5093
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5194

.github/workflows/scripts/create-package.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/scripts/extract-version.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)