Repository navigation
79 lines (67 loc) · 2.61 KB
/
Copy pathcreate-zip.yml
File metadata and controls
79 lines (67 loc) · 2.61 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
name: Create zip
on:
push:
workflow_dispatch:
permissions:
actions: read
contents: write
jobs:
build-zip:
name: New zip file
runs-on: ubuntu-24.04
# Security: 1. Check for [zip] tag. 2. Check if user is authorized.
if: |
(github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[zip]')) &&
contains(fromJson('["kagg-design", "e271828-"]'), github.actor)
env:
SLUG: "hcaptcha-for-forms-and-more"
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies with caching
uses: hCaptcha/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4.0.0
with:
composer-options: "--no-dev --optimize-autoloader --classmap-authoritative"
- name: Install JS packages
run: |
corepack enable
yarn set version stable
yarn
yarn prod
- name: Get version from PHP file
id: get_version
shell: bash
run: |
VERSION=$(grep -oP "const HCAPTCHA_VERSION = '\K[^']+" hcaptcha.php)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create zip file
id: make_zip
shell: bash
run: |
echo "➤ Creating target directory..."
mkdir -p trunk/${SLUG}
echo "➤ Copying files..."
rsync -rc --exclude-from="$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/${SLUG}/ --delete --delete-excluded
echo "➤ Generating zip file..."
cd trunk
zip -r "${{ github.workspace }}/${{ env.SLUG }}.${{ env.VERSION }}.zip" .
echo "zip-path=${GITHUB_WORKSPACE}/${SLUG}.${VERSION}.zip" >> "${GITHUB_OUTPUT}"
echo "✓ Zip file generated!"
- name: Create pre-release (published) and upload asset
uses: hCaptcha/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda #v3.0.0
with:
files: ${{ github.workspace }}/${{ env.SLUG }}.${{ env.VERSION }}.zip
draft: false
prerelease: true
tag_name: v${{ env.VERSION }}
name: "v${{ env.VERSION }} (build ${{ github.run_number }})"
body: |
Automated pre-release for testing.
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print pre-release URL
run: |
echo "Pre-release URL:"
echo "https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/${{ env.SLUG }}.${{ env.VERSION }}.zip"