Skip to content

Commit d106408

Browse files
committed
Merge branch 'build-git-test' of github.com:openimsdk/actions-test into build-git-test
2 parents fb3feb8 + 854620a commit d106408

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Create Git Branch Package on Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
create-package:
9+
runs-on: ubuntu-latest
10+
env:
11+
TAG_VERSION: ${{ github.event.release.tag_name }}
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
submodules: "recursive"
20+
21+
- name: Create custom source code packages
22+
# env:
23+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
PROJECT_NAME="${{ github.event.repository.name }}"
27+
echo "Project name: $PROJECT_NAME"
28+
echo "Tag version: ${{ env.TAG_VERSION }}"
29+
30+
CURRENT_BRANCH=""
31+
32+
if [ ! -z "${{ github.event.release.target_commitish }}" ]; then
33+
CURRENT_BRANCH="${{ github.event.release.target_commitish }}"
34+
echo "Branch from release target_commitish: $CURRENT_BRANCH"
35+
fi
36+
37+
if [ -z "$CURRENT_BRANCH" ]; then
38+
CURRENT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")
39+
echo "Branch from git HEAD: $CURRENT_BRANCH"
40+
fi
41+
42+
echo "Final branch to use: $CURRENT_BRANCH"
43+
44+
mkdir -p temp-package
45+
46+
echo "Cloning single branch with full history..."
47+
# REPO_URL="https://github.com/${{ github.repository }}.git"
48+
REPO_URL="https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
49+
50+
# git clone --single-branch --branch "$CURRENT_BRANCH" "$REPO_URL" temp-package/$PROJECT_NAME-${{ env.TAG_VERSION }}
51+
gh repo clone ${{ github.repository }} temp-package/$PROJECT_NAME-${{ env.TAG_VERSION }} -- --single-branch --branch "$CURRENT_BRANCH"
52+
53+
cd temp-package/$PROJECT_NAME-${{ env.TAG_VERSION }}
54+
55+
git config user.name "github-actions[bot]"
56+
git config user.email "github-actions[bot]@users.noreply.github.com"
57+
58+
# create version file
59+
mkdir -p version
60+
echo "${{ env.TAG_VERSION }}" > version/version
61+
62+
echo "Version file content after update:"
63+
cat version/version
64+
65+
git add version/version
66+
git commit -m "Update version to ${{ env.TAG_VERSION }}"
67+
68+
# Remove remote reference
69+
git remote remove origin
70+
71+
git tag | xargs -r git tag -d
72+
73+
echo "Final git status in package:"
74+
git branch -a 2>/dev/null || echo "No git branches found"
75+
git log --oneline -5 2>/dev/null || echo "No git history found"
76+
git remote -v 2>/dev/null || echo "No remotes found"
77+
78+
cd ..
79+
80+
zip -r ../$PROJECT_NAME-${{ env.TAG_VERSION }}-with-git.zip $PROJECT_NAME-${{ env.TAG_VERSION }}/
81+
tar -czf ../$PROJECT_NAME-${{ env.TAG_VERSION }}-with-git.tar.gz $PROJECT_NAME-${{ env.TAG_VERSION }}/
82+
83+
# cd ..
84+
85+
# echo "Created files:"
86+
# ls -la $PROJECT_NAME-${{ env.TAG_VERSION }}-with-git.*
87+
# echo "File sizes:"
88+
# du -h $PROJECT_NAME-${{ env.TAG_VERSION }}-with-git.*
89+
90+
# echo "ZIP contents (first 20 lines):"
91+
# unzip -l $PROJECT_NAME-${{ env.TAG_VERSION }}-with-git.zip | head -20
92+
# echo "TAR.GZ contents (first 20 lines):"
93+
# tar -tzf $PROJECT_NAME-${{ env.TAG_VERSION }}-with-git.tar.gz | head -20
94+
95+
- name: Upload custom source packages to existing release
96+
uses: softprops/action-gh-release@v2
97+
with:
98+
tag_name: ${{ env.TAG_VERSION }}
99+
files: |
100+
${{ github.event.repository.name }}-${{ env.TAG_VERSION }}-with-git.zip
101+
${{ github.event.repository.name }}-${{ env.TAG_VERSION }}-with-git.tar.gz
102+
append_body: true
103+
fail_on_unmatched_files: true
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)