This commit is contained in:
Michał Zieliński
2025-09-12 11:59:42 +02:00
parent 0d911cfc68
commit c0ca32c46f

View File

@@ -124,69 +124,28 @@ jobs:
if-no-files-found: error
retention-days: 7
publish-build:
needs: [ build-frontend, build-backend ]
copy-artifacts:
runs-on: ubuntu-latest
steps:
- uses: https://github.com/actions/checkout@v4
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: webapi
path: build/webapi
- name: Tools
- name: Store artifacts locally on runner
if: success()
run: |
apt-get update -y
apt-get install -y jq unzip zip curl
- name: Download frontend
uses: https://github.com/actions/download-artifact@v3
with: { name: frontend, path: ./release/frontend }
- name: Download backend
uses: https://github.com/actions/download-artifact@v3
with: { name: webapi, path: ./release/webapi }
- name: Zip artifacts
run: |
(cd release/frontend && zip -r ../DiunaBI-Morska-Frontend.zip .)
(cd release/webapi && zip -r ../DiunaBI-Morska-WebApi.zip .)
ls -la release
- name: Create or update release (tag build-main-latest)
id: rel
env:
API: "${{ github.server_url }}/api/v1"
OWNER: "${{ github.repository_owner }}"
REPO: "${{ github.event.repository.name }}"
TOKEN: "${{ secrets.GITEATOKEN }}"
run: |
set -euo pipefail
TAG="build-main-latest"
# spróbuj pobrać release po tagu
if curl -sfSL -H "Authorization: token $TOKEN" "$API/repos/$OWNER/$REPO/releases/tags/$TAG" -o rel.json; then
ID=$(jq -r '.id' rel.json)
else
# utwórz release
DATA=$(jq -n --arg tag "$TAG" --arg name "Latest build for main" \
--arg sha "${{ github.sha }}" '{tag_name:$tag,name:$name,target_commitish:$sha,prerelease:true,draft:false}')
curl -sfSL -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
-d "$DATA" "$API/repos/$OWNER/$REPO/releases" -o rel.json
ID=$(jq -r '.id' rel.json)
fi
echo "id=$ID" >> $GITHUB_OUTPUT
- name: Upload assets to release
env:
API: "${{ github.server_url }}/api/v1"
OWNER: "${{ github.repository_owner }}"
REPO: "${{ github.event.repository.name }}"
TOKEN: "${{ secrets.GITEATOKEN }}"
RID: "${{ steps.rel.outputs.id }}"
run: |
set -euo pipefail
upload() {
local file="$1" name="$2"
curl -sfSL -H "Authorization: token $TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@${file}" \
"$API/repos/$OWNER/$REPO/releases/$RID/assets?name=${name}" >/dev/null
}
upload "release/DiunaBI-Morska-Frontend.zip" "DiunaBI-Morska-Frontend.zip"
upload "release/DiunaBI-Morska-WebApi.zip" "DiunaBI-Morska-WebApi.zip"
BUILD_DIR="/runner-cache/builds/$GITHUB_RUN_ID"
mkdir -p "$BUILD_DIR"
cp -r build/webapi/ "$BUILD_DIR/"
cp -r src/Frontend/dist/ "$BUILD_DIR/frontend/"
ln -sfn "$BUILD_DIR" /runner-cache/builds/latest
echo "BUILD_TIME=$(date -Iseconds)" > "$BUILD_DIR/build-info.txt"
echo "COMMIT_SHA=${GITHUB_SHA}" >> "$BUILD_DIR/build-info.txt"
echo "BRANCH=${GITHUB_REF_NAME}" >> "$BUILD_DIR/build-info.txt"
echo "BUILD_ID=${GITHUB_RUN_ID}" >> "$BUILD_DIR/build-info.txt"
ls -la "$BUILD_DIR/"