build
This commit is contained in:
@@ -124,69 +124,28 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
publish-build:
|
copy-artifacts:
|
||||||
needs: [ build-frontend, build-backend ]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
- name: Upload artifact
|
||||||
- uses: https://github.com/actions/checkout@v4
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: webapi
|
||||||
|
path: build/webapi
|
||||||
|
|
||||||
- name: Tools
|
- name: Store artifacts locally on runner
|
||||||
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
apt-get update -y
|
BUILD_DIR="/runner-cache/builds/$GITHUB_RUN_ID"
|
||||||
apt-get install -y jq unzip zip curl
|
mkdir -p "$BUILD_DIR"
|
||||||
|
|
||||||
- name: Download frontend
|
cp -r build/webapi/ "$BUILD_DIR/"
|
||||||
uses: https://github.com/actions/download-artifact@v3
|
cp -r src/Frontend/dist/ "$BUILD_DIR/frontend/"
|
||||||
with: { name: frontend, path: ./release/frontend }
|
|
||||||
|
|
||||||
- name: Download backend
|
ln -sfn "$BUILD_DIR" /runner-cache/builds/latest
|
||||||
uses: https://github.com/actions/download-artifact@v3
|
|
||||||
with: { name: webapi, path: ./release/webapi }
|
|
||||||
|
|
||||||
- name: Zip artifacts
|
echo "BUILD_TIME=$(date -Iseconds)" > "$BUILD_DIR/build-info.txt"
|
||||||
run: |
|
echo "COMMIT_SHA=${GITHUB_SHA}" >> "$BUILD_DIR/build-info.txt"
|
||||||
(cd release/frontend && zip -r ../DiunaBI-Morska-Frontend.zip .)
|
echo "BRANCH=${GITHUB_REF_NAME}" >> "$BUILD_DIR/build-info.txt"
|
||||||
(cd release/webapi && zip -r ../DiunaBI-Morska-WebApi.zip .)
|
echo "BUILD_ID=${GITHUB_RUN_ID}" >> "$BUILD_DIR/build-info.txt"
|
||||||
ls -la release
|
|
||||||
|
|
||||||
- name: Create or update release (tag build-main-latest)
|
ls -la "$BUILD_DIR/"
|
||||||
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"
|
|
||||||
Reference in New Issue
Block a user