@@ -57,12 +57,46 @@ jobs:
5757 run : |
5858 if git diff --quiet -- cdm.json; then
5959 echo "changed=false" >> "$GITHUB_OUTPUT"
60- echo "cdm.json already matches the latest ${CDM_NETWORK} contract manifest." >> "$GITHUB_STEP_SUMMARY"
6160 else
6261 echo "changed=true" >> "$GITHUB_OUTPUT"
6362 echo "cdm.json changed after cdm i -n ${CDM_NETWORK}." >> "$GITHUB_STEP_SUMMARY"
6463 fi
6564
65+ - name : Check current release
66+ if : steps.manifest.outputs.changed == 'false'
67+ id : current_release
68+ env :
69+ GH_TOKEN : ${{ github.token }}
70+ run : |
71+ VERSION=$(node -p "require('./package.json').version")
72+ TAG="v${VERSION}"
73+ COMMIT=$(git rev-parse HEAD)
74+
75+ echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
76+ echo "commit=${COMMIT}" >> "$GITHUB_OUTPUT"
77+
78+ EXPECTED_ASSETS=(dot-linux-x64 dot-linux-arm64 dot-darwin-x64 dot-darwin-arm64)
79+ if ! RELEASE_ASSETS=$(gh release view "${TAG}" --json assets --jq '.assets[].name' 2>/dev/null); then
80+ echo "missing=true" >> "$GITHUB_OUTPUT"
81+ echo "cdm.json is unchanged, but ${TAG} has no GitHub release. Rebuilding the current version." >> "$GITHUB_STEP_SUMMARY"
82+ exit 0
83+ fi
84+
85+ missing_assets=()
86+ for asset in "${EXPECTED_ASSETS[@]}"; do
87+ if ! grep -Fxq "${asset}" <<< "${RELEASE_ASSETS}"; then
88+ missing_assets+=("${asset}")
89+ fi
90+ done
91+
92+ if [ "${#missing_assets[@]}" -eq 0 ]; then
93+ echo "missing=false" >> "$GITHUB_OUTPUT"
94+ echo "cdm.json already matches the latest ${CDM_NETWORK} contract manifest and ${TAG} already has all binary assets." >> "$GITHUB_STEP_SUMMARY"
95+ else
96+ echo "missing=true" >> "$GITHUB_OUTPUT"
97+ echo "${TAG} is missing binary assets: ${missing_assets[*]}. Rebuilding the current version." >> "$GITHUB_STEP_SUMMARY"
98+ fi
99+
66100 - name : Create patch changeset
67101 if : steps.manifest.outputs.changed == 'true'
68102 run : |
@@ -85,40 +119,44 @@ jobs:
85119 if : steps.manifest.outputs.changed == 'true'
86120 run : pnpm format
87121
88- - name : Commit release changes
122+ - name : Generate release tag
89123 if : steps.manifest.outputs.changed == 'true'
124+ id : tag
90125 run : |
91- git config user.name "github-actions[bot]"
92- git config user.email "github-actions[bot]@users.noreply.github.com"
93- git add cdm.json package.json CHANGELOG.md pnpm-lock.yaml
94- git diff --cached --quiet || git commit -m "chore: release contract manifest update"
95- git push origin HEAD:main
126+ VERSION=$(node -p "require('./package.json').version")
127+ TAG="v${VERSION}"
128+ echo "tag=$TAG" >> "$GITHUB_OUTPUT"
96129
97130 - name : Compile CLI binaries
98- if : steps.manifest.outputs.changed == 'true'
131+ if : steps.manifest.outputs.changed == 'true' || steps.current_release.outputs.missing == 'true'
99132 run : |
100133 bun build --compile --target=bun-linux-x64 src/index.ts --outfile dot-linux-x64
101134 bun build --compile --target=bun-linux-arm64 src/index.ts --outfile dot-linux-arm64
102135 bun build --compile --target=bun-darwin-x64 src/index.ts --outfile dot-darwin-x64
103136 bun build --compile --target=bun-darwin-arm64 src/index.ts --outfile dot-darwin-arm64
104137
105- - name : Generate release tag
138+ - name : Commit release changes
106139 if : steps.manifest.outputs.changed == 'true'
107- id : tag
140+ id : commit
108141 run : |
109- VERSION=$(node -p "require('./package.json').version")
110- TAG="v${VERSION}"
111- echo "tag=$TAG" >> "$GITHUB_OUTPUT"
142+ git config user.name "github-actions[bot]"
143+ git config user.email "github-actions[bot]@users.noreply.github.com"
144+ git add cdm.json package.json CHANGELOG.md pnpm-lock.yaml
145+ git diff --cached --quiet || git commit -m "chore: release contract manifest update"
146+ echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
147+ git push origin HEAD:main
112148
113149 - name : Create GitHub Release
114- if : steps.manifest.outputs.changed == 'true'
150+ if : steps.manifest.outputs.changed == 'true' || steps.current_release.outputs.missing == 'true'
115151 uses : softprops/action-gh-release@v2
116152 with :
117- tag_name : ${{ steps.tag.outputs.tag }}
118- name : Release ${{ steps.tag.outputs.tag }}
153+ tag_name : ${{ steps.manifest.outputs.changed == 'true' && steps.tag.outputs.tag || steps.current_release.outputs.tag }}
154+ target_commitish : ${{ steps.manifest.outputs.changed == 'true' && steps.commit.outputs.commit || steps.current_release.outputs.commit }}
155+ name : Release ${{ steps.manifest.outputs.changed == 'true' && steps.tag.outputs.tag || steps.current_release.outputs.tag }}
119156 files : |
120157 dot-linux-x64
121158 dot-linux-arm64
122159 dot-darwin-x64
123160 dot-darwin-arm64
161+ overwrite_files : true
124162 generate_release_notes : true
0 commit comments