parent
bbb6ec199a
commit
a184a3d636
|
|
@ -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 @- <<EOF
|
||||
{
|
||||
"tag_name": "${{ env.TAG_NAME }}",
|
||||
"name": "Release ${{ env.TAG_NAME }}",
|
||||
"body": "This release was created automatically by GitHub Actions.",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "$response" | tee gitea-release-response.json
|
||||
RELEASE_ID=$(echo "$response" | jq -r '.id')
|
||||
|
||||
if [ "$RELEASE_ID" = "null" ]; then
|
||||
echo "❌ Failed to create release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV
|
||||
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
|
||||
#- name: setup go
|
||||
# uses: actions/setup-go@v5
|
||||
# with:
|
||||
|
|
|
|||
Loading…
Reference in New Issue