diff --git a/.drone.yml b/.drone.yml index 2011d3f..92c0636 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,20 +14,24 @@ trigger: steps: - name: build - environment: - PASSWORD: - from_secret: password commands: - npm ci - vsce package - name: gitea_release - image: plugins/gitea-release - settings: - base_url: https://gitea.raphaelpiccolo.com - files: "*.vsix" - api_key: + environment: + GITEA_TOKEN: from_secret: gitea_token + commands: + - bash gitearelease.sh + + # - name: gitea_release + # image: plugins/gitea-release + # settings: + # base_url: https://gitea.raphaelpiccolo.com + # files: "*.vsix" + # api_key: + # from_secret: gitea_token # - name: deploy # environment: diff --git a/gitearelease.sh b/gitearelease.sh new file mode 100644 index 0000000..9843375 --- /dev/null +++ b/gitearelease.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Variables +# GITEA_TOKEN="" +# DRONE_TAG="1.1.6" +# DRONE_REPO_NAME="vscodestat" +# DRONE_REPO_OWNER="root" +GITEA_API_URL="https://gitea.raphaelpiccolo.com/api/v1" +TAG_NAME="v${DRONE_TAG}" +RELEASE_NAME="Release ${DRONE_TAG}" +RELEASE_BODY="vscode extension generated" +ARTIFACT_PATH="${DRONE_REPO_NAME}-${DRONE_TAG}.vsix" + +# Create a release +response=$(curl -s -X POST "${GITEA_API_URL}/repos/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/releases" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"${TAG_NAME}\", + \"name\": \"${RELEASE_NAME}\", + \"body\": \"${RELEASE_BODY}\", + \"draft\": false, + \"prerelease\": false + }") + +# Extract release ID from the response +release_id=$(echo $response | jq '.id') + +if [ -z "$release_id" ]; then + echo "Failed to create release" + exit 1 +fi + +# Upload the artifact +curl -s -X POST "${GITEA_API_URL}/repos/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/releases/${release_id}/assets?name=$(basename ${ARTIFACT_PATH})" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: $(file -b --mime-type ${ARTIFACT_PATH})" \ + --data-binary @"${ARTIFACT_PATH}" + +echo "Artifact uploaded successfully." diff --git a/package-lock.json b/package-lock.json index 6bce812..4a1aaac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscodestat", - "version": "1.1.6", + "version": "1.1.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vscodestat", - "version": "1.1.6", + "version": "1.1.7", "license": "ISC", "devDependencies": { "@types/mocha": "^10.0.7", diff --git a/package.json b/package.json index 3b3eb8a..9bc650d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vscodestat", "displayName": "vscodestat", - "version": "1.1.6", + "version": "1.1.7", "description": "", "categories": [ "Other"