80 lines
3.3 KiB
YAML
80 lines
3.3 KiB
YAML
name: Gitea Actions Demo
|
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
|
on: [push]
|
|
|
|
jobs:
|
|
Explore-Gitea-Actions:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
|
- run: |
|
|
echo "Setting global proxy in /etc/environment"
|
|
echo "http_proxy=http://172.130.0.24:7890" | sudo tee -a /etc/environment
|
|
echo "https_proxy=http://172.130.0.24:7890" | sudo tee -a /etc/environment
|
|
echo "all_proxy=socks5h://172.130.0.24:7890" | sudo tee -a /etc/environment
|
|
source /etc/environment
|
|
echo "Proxies configured globally"
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v4
|
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
|
- name: List files in the repository
|
|
run: |
|
|
ls ${{ gitea.workspace }}
|
|
- name: add xmake repo
|
|
run: add-apt-repository ppa:xmake-io/xmake -y
|
|
- name: install xmake
|
|
run: apt install xmake -y
|
|
- name: compile the repo
|
|
run: xmake build --root
|
|
- name: Package Build Artifacts
|
|
run: |
|
|
mkdir -p output
|
|
cp -r ./build output/
|
|
tar -czvf release.tar.gz output/
|
|
- name: Extract Release Info from Git
|
|
id: release_info
|
|
run: |
|
|
TAG_NAME=$(git describe --tags --abbrev=0)
|
|
echo "tag_name=$TAG_NAME" >> $GITHUB_ENV
|
|
|
|
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
|
|
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
|
|
|
|
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
|
|
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_ENV
|
|
|
|
echo "Tag Name: $TAG_NAME"
|
|
echo "Branch Name: $BRANCH_NAME"
|
|
echo "Commit Message: $COMMIT_MESSAGE"
|
|
- name: Upload to Gitea Release
|
|
env:
|
|
GITEA_TOKEN: 832220f0243e86d7f10579700a65115124be4f19
|
|
run: |
|
|
# 创建 Release
|
|
RELEASE_DATA=$(curl -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"$GITHUB_ENV\",
|
|
\"target_commitish\": \"$branch_name\",
|
|
\"name\": \"$tag_name\",
|
|
\"body\": \"$commit_message\",
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}" \
|
|
https://git.luo980.site/api/v1/repos/luo980/xmake-helloworld-runner/releases)
|
|
# 提取 Release ID
|
|
RELEASE_ID=$(echo "$RELEASE_DATA" | jq -r '.id')
|
|
|
|
echo "Release id is $RELEASE_ID"
|
|
|
|
# 上传文件
|
|
curl -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary @release.tar.gz \
|
|
https://git.luo980.site/api/v1/repos/luo980/xmake-helloworld-runner/releases/$RELEASE_ID/assets?name=release.tar.gz
|
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
|
|