From fc38929eed5560705ac33c61636a31f0fd68c8e7 Mon Sep 17 00:00:00 2001 From: Stephen Leitnick Date: Mon, 13 Jan 2025 00:39:11 -0500 Subject: [PATCH] Fix release --- .github/workflows/release.yaml | 8 +++- check_version.py => scripts/check_version.py | 0 scripts/move_releases.py | 48 ++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) rename check_version.py => scripts/check_version.py (100%) create mode 100644 scripts/move_releases.py diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 81a63da..8dfa331 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,7 +18,7 @@ jobs: python-version: "3.x" - name: Check tag version against cargo version - run: python check_version.py ${{ github.ref_name }} + run: python scripts/check_version.py ${{ github.ref_name }} build: needs: ["check-release-version"] @@ -88,7 +88,7 @@ jobs: - name: Upload Archive to Artifacts uses: actions/upload-artifact@v4 with: - name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }}.zip + name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }} path: release.zip create-release: @@ -106,12 +106,16 @@ jobs: with: path: gh_artifacts + - name: Move releases + run: python -u scripts/move_releases.py gh_artifacts + - name: Create release id: create_release uses: softprops/action-gh-release@v2 with: draft: true generate_release_notes: true + fail_on_unmatched_files: true files: gh_artifacts/*.zip publish: diff --git a/check_version.py b/scripts/check_version.py similarity index 100% rename from check_version.py rename to scripts/check_version.py diff --git a/scripts/move_releases.py b/scripts/move_releases.py new file mode 100644 index 0000000..942c022 --- /dev/null +++ b/scripts/move_releases.py @@ -0,0 +1,48 @@ +import sys +import os + + +def main(): + args = sys.argv + n_args = len(args) + if n_args <= 1: + print("no path argument found", file=sys.stderr) + exit(1) + + path = args[1] + + expected = 0 + total = 0 + + for child_path in os.listdir(path): + filepath = os.path.join(path, child_path) + + if not os.path.isdir(filepath): + print(f"{filepath} is not a dir") + continue + + expected += 1 + + release_filepath = os.path.join(filepath, "release.zip") + if not os.path.isfile(release_filepath): + print(f"no release.zip file found in {filepath}", file=sys.stderr) + continue + + target_filepath = f"{filepath}.zip" + os.rename(release_filepath, target_filepath) + + total += 1 + print(target_filepath) + + if total < expected: + print(f"{total}/{expected} succeeded [{total - expected} failed]", file=sys.stderr) + exit(1) + elif total == 0: + print("no work", file=sys.stderr) + exit(1) + + print("done") + + +if __name__ == "__main__": + main()