diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 2545b52..d4a347c 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -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" \ No newline at end of file + 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/" \ No newline at end of file