40 lines
1.7 KiB
YAML
40 lines
1.7 KiB
YAML
name: Create Forgejo release
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*.*.*']
|
|
|
|
jobs:
|
|
package-and-release:
|
|
# Uses the existing Forgejo runner label. Docker is not required on the runner.
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out source
|
|
uses: https://data.forgejo.org/actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Create release archive and checksum
|
|
run: |
|
|
mkdir -p dist
|
|
ARCHIVE="my-resume2-${FORGEJO_REF_NAME}.tar.gz"
|
|
git archive --format=tar.gz --prefix="my-resume2-${FORGEJO_REF_NAME}/" -o "dist/${ARCHIVE}" "$FORGEJO_SHA"
|
|
sha256sum "dist/${ARCHIVE}" > "dist/${ARCHIVE}.sha256"
|
|
- name: Create the Forgejo release
|
|
run: |
|
|
cat > release.json <<EOF
|
|
{"tag_name":"${FORGEJO_REF_NAME}","target_commitish":"${FORGEJO_SHA}","name":"${FORGEJO_REF_NAME}","body":"Local Docker deployment package. Build it on the target server with docker compose; no container image is published.","draft":false,"prerelease":false}
|
|
EOF
|
|
curl --fail --request POST \
|
|
--header "Authorization: token ${FORGEJO_TOKEN}" \
|
|
--header "Content-Type: application/json" \
|
|
--data @release.json \
|
|
"${FORGEJO_SERVER_URL}/api/v1/repos/${FORGEJO_REPOSITORY}/releases" > created-release.json
|
|
- name: Upload release files
|
|
run: |
|
|
RELEASE_ID=$(node -p "require('./created-release.json').id")
|
|
for FILE in dist/*; do
|
|
curl --fail --request POST \
|
|
--header "Authorization: token ${FORGEJO_TOKEN}" \
|
|
--upload-file "$FILE" \
|
|
"${FORGEJO_SERVER_URL}/api/v1/repos/${FORGEJO_REPOSITORY}/releases/${RELEASE_ID}/assets?name=$(basename "$FILE")"
|
|
done
|