-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (79 loc) · 3.42 KB
/
package-release.yml
File metadata and controls
94 lines (79 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Package and Release Tarot Decks
permissions:
contents: write
on:
workflow_dispatch:
inputs:
deck_name:
description: 'Deck to package (e.g., rider-waite-smith)'
required: true
default: 'rider-waite-smith'
push:
branches:
- main
tags:
- '*/*' # Matches tags like rider-waite-smith/v1.0
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set deck name
id: deck
run: |
# Use input deck name for manual triggers, otherwise default to rider-waite-smith
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
DECK_NAME="${{ github.event.inputs.deck_name }}"
else
# For tag pushes, extract deck name from tag (e.g., rider-waite-smith/v1.0 -> rider-waite-smith)
if [[ "${{ github.ref_type }}" == "tag" ]]; then
TAG_NAME="${{ github.ref_name }}"
DECK_NAME=$(echo $TAG_NAME | cut -d'/' -f1)
else
# Default to rider-waite-smith for branch pushes
DECK_NAME="rider-waite-smith"
fi
fi
echo "Using deck: $DECK_NAME"
echo "deck_name=$DECK_NAME" >> $GITHUB_OUTPUT
- name: Extract version and package deck
id: package
run: |
DECK_NAME="${{ steps.deck.outputs.deck_name }}"
# Make sure the deck directory exists
if [ ! -d "$DECK_NAME" ]; then
echo "Error: Deck directory '$DECK_NAME' not found!"
exit 1
fi
VERSION=$(grep -E '^version\s*=\s*"[^"]+"' $DECK_NAME/deck.toml | sed -E 's/^version\s*=\s*"([^"]+)"/\1/')
echo "Found version: $VERSION"
# Extract human-readable name from deck.toml
DISPLAY_NAME=$(grep -E '^name\s*=\s*"[^"]+"' $DECK_NAME/deck.toml | sed -E 's/^name\s*=\s*"([^"]+)"/\1/' || echo "$DECK_NAME")
echo "Display name: $DISPLAY_NAME"
# Create package name
PACKAGE_NAME="${DECK_NAME}-${VERSION}"
ZIP_FILE="${PACKAGE_NAME}.zip"
echo "Creating package: $ZIP_FILE"
# Create the zip file
zip -r "${ZIP_FILE}" $DECK_NAME
ls -la "${ZIP_FILE}"
# Set output variables
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "zip_file=$ZIP_FILE" >> $GITHUB_OUTPUT
echo "display_name=$DISPLAY_NAME" >> $GITHUB_OUTPUT
echo "tag_name=${{ steps.deck.outputs.deck_name}}/v${VERSION}" >> $GITHUB_OUTPUT
- name: Create Release
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.package.outputs.zip_file }}
name: ${{ steps.package.outputs.display_name }} v${{ steps.package.outputs.version }}
tag_name: ${{ steps.package.outputs.tag_name }}
draft: false
prerelease: false
body: |
# ${{ steps.package.outputs.display_name }} Tarot Deck v${{ steps.package.outputs.version }}
This release contains the ${{ steps.package.outputs.display_name }} deck in the format described by the [Tarot Deck Specification](https://github.com/arcanaland/specifications).
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}