@@ -2,6 +2,9 @@ name: Build Release
22
33on :
44 push :
5+ branches :
6+ - master
7+ - main
58 tags :
69 - " v*.*.*"
710 workflow_dispatch :
@@ -35,20 +38,28 @@ jobs:
3538 set -euo pipefail
3639 git fetch --force --tags
3740
41+ SHOULD_PUBLISH="false"
42+
3843 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
3944 TAG="${{ inputs.tag }}"
45+ SHOULD_PUBLISH="true"
4046 if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
4147 git checkout --detach "refs/tags/${TAG}"
4248 else
4349 echo "::notice::Tag ${TAG} does not exist yet. Building current commit and creating tag via release."
4450 fi
45- else
51+ elif [ "${GITHUB_REF_TYPE}" = "tag" ]; then
4652 TAG="${GITHUB_REF_NAME}"
53+ SHOULD_PUBLISH="true"
4754 git checkout --detach "refs/tags/${TAG}"
55+ else
56+ TAG="snapshot-${GITHUB_SHA::7}"
57+ echo "::notice::Branch push detected (${GITHUB_REF_NAME}); building snapshot artifacts with tag ${TAG}."
4858 fi
4959
5060 echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
5161 echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
62+ echo "should_publish=${SHOULD_PUBLISH}" >> "$GITHUB_OUTPUT"
5263
5364 - name : Setup pnpm
5465 uses : pnpm/action-setup@v4
95106 echo "sha=${SHA}" >> "$GITHUB_OUTPUT"
96107
97108 - name : Publish GitHub Release
109+ if : steps.ref.outputs.should_publish == 'true'
98110 uses : softprops/action-gh-release@v2
99111 with :
100112 tag_name : ${{ steps.ref.outputs.tag }}
@@ -104,3 +116,12 @@ jobs:
104116 files : |
105117 ${{ steps.pkg.outputs.archive }}
106118 ${{ steps.pkg.outputs.sha }}
119+
120+ - name : Upload snapshot artifacts
121+ if : steps.ref.outputs.should_publish != 'true'
122+ uses : actions/upload-artifact@v4
123+ with :
124+ name : nitrocraft-${{ steps.ref.outputs.tag }}-node-server
125+ path : |
126+ ${{ steps.pkg.outputs.archive }}
127+ ${{ steps.pkg.outputs.sha }}
0 commit comments