1 parent
a993080fe6
commit
d70baec3ec
1 file changed
+62
@@ -0,0 +1,62 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ published ]
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
upload-asset:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:7.4-cli
|
||||
|
||||
steps:
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq git unzip zip curl jq
|
||||
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build release zip
|
||||
run: |
|
||||
mkdir -p release/laps
|
||||
git archive HEAD | tar -x -C release/laps
|
||||
cd release/laps
|
||||
composer config platform.php 7.4
|
||||
composer remove composer/installers --no-update
|
||||
composer update --no-dev --optimize-autoloader
|
||||
cd ..
|
||||
zip -q -r laps.zip laps
|
||||
rm -rf laps
|
||||
|
||||
- name: Upload zip to Gitea Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITEA_URL: ${{ github.server_url }}
|
||||
REPO: ${{ github.repository }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$GITEA_URL/api/v1/repos/$REPO/releases/tags/$TAG")
|
||||
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r .id)
|
||||
|
||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
||||
echo "Creating release for tag $TAG..."
|
||||
CREATE_RES=$(curl -s -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"Release $TAG\"}" \
|
||||
"$GITEA_URL/api/v1/repos/$REPO/releases")
|
||||
RELEASE_ID=$(echo "$CREATE_RES" | jq -r .id)
|
||||
fi
|
||||
|
||||
echo "Uploading laps.zip to release ID $RELEASE_ID..."
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "attachment=@release/laps.zip" \
|
||||
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=laps.zip"
|
||||
Reference in new issue
Block a user