Skip to content

Commit 4d4cd3d

Browse files
committed
re: auto tag git
1 parent 2d2dda8 commit 4d4cd3d

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

.github/workflows/openscad-export.yml

+34-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
name: OpenSCAD Export to STL
1+
name: OpenSCAD Export to STL and Auto-Tag
22

33
on:
44
push:
55
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
86
workflow_dispatch:
97

108
jobs:
11-
export-stl:
9+
export-stl-and-tag:
1210
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
actions: read
1314
steps:
1415
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0 # Fetch all history for all tags and branches
1518

1619
- name: Install OpenSCAD
1720
run: |
@@ -29,26 +32,29 @@ jobs:
2932
run: |
3033
cat stl_files/*.stl > combined.stl
3134
32-
- name: Upload individual STL files
33-
uses: actions/upload-artifact@v2
34-
with:
35-
name: stl-files
36-
path: stl_files/*.stl
35+
- name: Generate new tag
36+
id: tag_version
37+
run: |
38+
git fetch --tags
39+
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
40+
new_tag=$(echo $latest_tag | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
41+
echo "NEW_TAG=$new_tag" >> $GITHUB_OUTPUT
3742
38-
- name: Upload combined STL file
39-
uses: actions/upload-artifact@v2
40-
with:
41-
name: combined-stl
42-
path: combined.stl
43+
- name: Create and push tag
44+
run: |
45+
git config user.name github-actions
46+
git config user.email [email protected]
47+
git tag ${{ steps.tag_version.outputs.NEW_TAG }}
48+
git push origin ${{ steps.tag_version.outputs.NEW_TAG }}
4349
4450
- name: Create Release
4551
id: create_release
4652
uses: actions/create-release@v1
4753
env:
4854
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4955
with:
50-
tag_name: ${{ github.ref }}
51-
release_name: Release ${{ github.ref }}
56+
tag_name: ${{ steps.tag_version.outputs.NEW_TAG }}
57+
release_name: Release ${{ steps.tag_version.outputs.NEW_TAG }}
5258
draft: false
5359
prerelease: false
5460

@@ -62,3 +68,15 @@ jobs:
6268
asset_name: combined.stl
6369
asset_content_type: model/stl
6470

71+
- name: Upload individual STL files
72+
uses: actions/upload-artifact@v2
73+
with:
74+
name: stl-files
75+
path: stl_files/*.stl
76+
77+
- name: Upload combined STL file
78+
uses: actions/upload-artifact@v2
79+
with:
80+
name: combined-stl
81+
path: combined.stl
82+

0 commit comments

Comments
 (0)