Skip to content

Commit fd58970

Browse files
committed
ci: create release workflows
1 parent 0005cb1 commit fd58970

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Package and Release Tarot Deck
2+
3+
on:
4+
# Manual trigger
5+
workflow_dispatch:
6+
# Run on push to main branch with tag
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- 'v*'
12+
13+
jobs:
14+
build-and-release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Set up environment
21+
run: |
22+
mkdir -p .github/workflows/scripts
23+
chmod +x .github/workflows/scripts/extract-version.sh
24+
chmod +x .github/workflows/scripts/create-package.sh
25+
26+
- name: Extract version
27+
id: version
28+
run: |
29+
VERSION=$(.github/workflows/scripts/extract-version.sh)
30+
echo "VERSION=$VERSION" >> $GITHUB_ENV
31+
echo "version=$VERSION" >> $GITHUB_OUTPUT
32+
33+
- name: Get current time
34+
id: current_time
35+
run: |
36+
echo "timestamp=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
37+
38+
- name: Create package
39+
id: create_package
40+
run: |
41+
OUTPUT=$(.github/workflows/scripts/create-package.sh "${{ steps.version.outputs.version }}" "${{ steps.current_time.outputs.timestamp }}")
42+
echo "PACKAGE_PATH=$OUTPUT" >> $GITHUB_ENV
43+
echo "package_path=$OUTPUT" >> $GITHUB_OUTPUT
44+
45+
- name: Create Release
46+
id: create_release
47+
uses: softprops/action-gh-release@v1
48+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
49+
with:
50+
files: ${{ steps.create_package.outputs.package_path }}
51+
name: Rider-Waite-Smith Tarot Deck v${{ steps.version.outputs.version }}
52+
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('v{0}', steps.version.outputs.version) }}
53+
draft: false
54+
prerelease: false
55+
body: |
56+
Rider-Waite-Smith Tarot Deck v${{ steps.version.outputs.version }}
57+
58+
This release contains the packaged Rider-Waite-Smith tarot deck according to the Tarot Deck Specification.
59+
60+
**Package Information:**
61+
- Version: ${{ steps.version.outputs.version }}
62+
- Build Date: ${{ steps.current_time.outputs.timestamp }}
63+
- Created by: ${{ github.actor }}
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Get the version from the first parameter
4+
VERSION=$1
5+
TIMESTAMP=$2
6+
7+
# Check if version was provided
8+
if [ -z "$VERSION" ]; then
9+
echo "ERROR: Version not provided" >&2
10+
exit 1
11+
fi
12+
13+
# Format the package name similar to common software package conventions
14+
# You can choose one of these formats by uncommenting the preferred one:
15+
16+
# Option 1: Simple format with version only
17+
PACKAGE_NAME="rider-waite-smith-${VERSION}"
18+
19+
# Option 2: RPM-like format with version and build date
20+
# PACKAGE_NAME="rider-waite-smith-${VERSION}-${TIMESTAMP}"
21+
22+
# Option 3: Debian-like format
23+
# PACKAGE_NAME="rider-waite-smith_${VERSION}_all"
24+
25+
# Option a standard format
26+
# PACKAGE_NAME="rider-waite-smith-v${VERSION}"
27+
28+
ZIP_FILE="${PACKAGE_NAME}.zip"
29+
30+
# Create a temporary directory for packaging
31+
TEMP_DIR=$(mktemp -d)
32+
DECK_DIR="${TEMP_DIR}/${PACKAGE_NAME}"
33+
34+
# Copy the rider-waite-smith directory to the temporary directory
35+
mkdir -p "${DECK_DIR}"
36+
cp -r rider-waite-smith/* "${DECK_DIR}/"
37+
38+
# Include metadata file with package info
39+
cat > "${DECK_DIR}/PACKAGE-INFO.txt" << EOL
40+
Package: Rider-Waite-Smith Tarot Deck
41+
Version: ${VERSION}
42+
Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
43+
Created By: ${GITHUB_ACTOR:-"GitHub Actions"}
44+
Repository: ${GITHUB_REPOSITORY:-"arcanaland/specifications"}
45+
46+
This package follows the Tarot Deck Specification v1.0.
47+
EOL
48+
49+
# Create the zip file
50+
(cd "${TEMP_DIR}" && zip -r "${ZIP_FILE}" "${PACKAGE_NAME}")
51+
52+
# Move the zip file to the current directory
53+
mv "${TEMP_DIR}/${ZIP_FILE}" .
54+
55+
# Clean up the temporary directory
56+
rm -rf "${TEMP_DIR}"
57+
58+
# Output the path to the zip file
59+
echo "${ZIP_FILE}"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# Extract version from deck.toml
4+
VERSION=$(grep -E '^version\s*=\s*"[^"]+"' rider-waite-smith/deck.toml | sed -E 's/^version\s*=\s*"([^"]+)"/\1/')
5+
6+
# Check if version was found
7+
if [ -z "$VERSION" ]; then
8+
echo "ERROR: Version not found in deck.toml" >&2
9+
exit 1
10+
fi
11+
12+
# Output the version
13+
echo "$VERSION"

0 commit comments

Comments
 (0)