From a184a3d6363dd3fe10ecef1f68b6194293727c85 Mon Sep 17 00:00:00 2001 From: xiehaijun Date: Mon, 28 Jul 2025 15:49:52 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/demo.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 发布生产 --- .gitea/workflows/demo.yaml | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 5ae5576..3b81895 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -220,6 +220,11 @@ jobs: download: needs: upload runs-on: ubuntu-latest + env: # 设置job下全steps的环境变量 + GITEA_API_URL: https://gitea.example.com/api/v1 + GITEA_USER: youruser + GITEA_REPO: yourrepo + ARTIFACT_FILE: dist/release.zip steps: - name: Checkout uses: actions/checkout@v4 @@ -240,6 +245,7 @@ jobs: git config user.email "actions@github.com" git tag -a ${{ steps.vars.outputs.tag }} -m "Automated release" # git push origin ${{ steps.vars.outputs.tag }} + # 前往你的 GitHub: https://github.com/settings/tokens;生成一个 classic token(建议)或 fine-grained token;选择至少:repo 权限 # git push https://x-access-token:${PAT_PUSH}@github.com/${REPO}.git "$TAG" git push https://${GITEA_USER}:${GITEA_PAT}@${GITEA_HOST}/${GITEA_REPO}.git "$TAG" - name: 获取跨job上游job的输出变量值 @@ -316,6 +322,44 @@ jobs: files: |- ./release/** - run: ls -R ./release/ + - name: Build or prepare artifact (example only) + run: | + mkdir -p dist + echo "Hello Gitea Release" > dist/README.txt + zip -j dist/release.zip dist/README.txt + - name: Extract tag name + id: vars + run: | + TAG_NAME="${GITHUB_REF##*/}" + echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + - name: Create Gitea Release + id: create_release + run: | + response=$(curl -s -X POST "${GITEA_API_URL}/repos/${GITEA_USER}/${GITEA_REPO}/releases" \ + -H "Authorization: token ${{ secrets.GITEA_PAT }}" \ + -H "Content-Type: application/json" \ + -d @- <> $GITHUB_ENV + echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT #- name: setup go # uses: actions/setup-go@v5 # with: