Skip to content

Commit 705fefd

Browse files
Update main.yml
1 parent fa75e2e commit 705fefd

1 file changed

Lines changed: 74 additions & 26 deletions

File tree

.github/workflows/main.yml

Lines changed: 74 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,79 @@
1-
on: [push]
2-
name: ashSecurityHeaders
1+
# .github/workflows/main.yml
2+
3+
name: Build and Upload Release Package
4+
5+
# Pemicu: Workflow ini HANYA berjalan saat sebuah rilis baru dibuat di GitHub
6+
on:
7+
release:
8+
types: [created]
9+
310
jobs:
4-
pluginTemplate:
11+
build-release-package:
512
runs-on: ubuntu-latest
6-
strategy:
7-
fail-fast: false
8-
matrix:
9-
include:
10-
- application: ojs
11-
php-version: 8.1
12-
database: mysql
13-
- application: ojs
14-
php-version: 7.4
15-
database: mysql
16-
- application: ojs
17-
php-version: 8.1
18-
database: pgsql
19-
- application: ojs
20-
php-version: 7.4
21-
database: pgsql
22-
23-
name: pluginTemplate
13+
# Izin diperlukan agar workflow bisa mengunggah aset ke rilis
14+
permissions:
15+
contents: write
16+
2417
steps:
25-
- uses: pkp/pkp-github-actions@v1
18+
# 1. Checkout kode dari tag yang memicu rilis ini
19+
- name: Checkout code
20+
uses: actions/checkout@v4
2621
with:
27-
node_version: 20
28-
branch: main
29-
repository: pkp
30-
plugin: true
22+
ref: ${{ github.event.release.tag_name }}
23+
24+
# 2. Dapatkan nama tag untuk digunakan dalam nama file
25+
- name: Get tag name
26+
run: |
27+
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
28+
29+
# 3. Buat paket rilis .tar.gz
30+
- name: Create release package
31+
run: |
32+
# Nama direktori root di dalam tarball, sesuai standar OJS
33+
PLUGIN_DIR_NAME="ashSecurityHeaders"
34+
35+
# Definisikan nama file tarball
36+
TARBALL="${PLUGIN_DIR_NAME}-${TAG_NAME}.tar.gz"
37+
TARBALL_PATH="$RUNNER_TEMP/${TARBALL}"
38+
39+
# Buat arsip .tar.gz
40+
# --transform akan menempatkan semua file ke dalam direktori PLUGIN_DIR_NAME
41+
tar -czf "${TARBALL_PATH}" \
42+
--exclude='.git' \
43+
--exclude='.github' \
44+
--exclude='cypress' \
45+
--exclude='tests' \
46+
--exclude='.gitignore' \
47+
--transform "s|^\.|${PLUGIN_DIR_NAME}|" \
48+
.
49+
50+
# Simpan nama dan path tarball untuk langkah selanjutnya
51+
echo "TARBALL=${TARBALL}" >> $GITHUB_ENV
52+
echo "TARBALL_PATH=${TARBALL_PATH}" >> $GITHUB_ENV
53+
54+
# 4. Hitung hash MD5 dari paket rilis
55+
- name: Calculate MD5 hash
56+
run: |
57+
MD5=$(md5sum $TARBALL_PATH | awk '{print $1}')
58+
echo "MD5 Hash: ${MD5}"
59+
echo "MD5=${MD5}" >> $GITHUB_ENV
60+
61+
# 5. Unggah paket .tar.gz sebagai aset ke halaman rilis
62+
- name: Upload package to release
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: |
66+
gh release upload $TAG_NAME $TARBALL_PATH --clobber
3167
68+
# 6. Perbarui catatan rilis dengan hash MD5
69+
- name: Update release notes with MD5
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
CURRENT_BODY="$(gh release view "$TAG_NAME" --json body --jq .body)"
74+
gh release edit $TAG_NAME --notes "$(
75+
printf '%s\n\n%s\n\n%s\n' \
76+
"${CURRENT_BODY}" \
77+
"## Download Verification" \
78+
"MD5 Hash for \`$TARBALL\`: \`$MD5\`"
79+
)"

0 commit comments

Comments
 (0)