From b80a5d92bbf74eb472ff1b02c5a302292bcbe027 Mon Sep 17 00:00:00 2001 From: James Elliott Date: Sat, 2 Mar 2024 19:07:58 -0600 Subject: [PATCH] Upgrade to KSC 0.10 And fix all the linting errors it now reports. This is a backwards incompatible change in our API, unfortunately. Also upgrade to the new GitHub CLI-based release management approach that Beat Link Trigger now uses. --- .github/resources/preview_notes.md | 3 +++ .github/resources/release_notes.md | 3 +++ .github/scripts/create_release.sh | 29 +++++++++++++++++++++ .github/scripts/delete_preview.sh | 21 +++++++++++++++ .github/scripts/finish_release.sh | 41 ++++++++++++++++++++++++++++++ .github/workflows/jar.yml | 32 +++++++++++------------ CHANGELOG.md | 25 +++++++++++++++++- pom.xml | 8 +++--- src/main/kaitai/rekordbox_anlz.ksy | 16 ++++++------ src/main/kaitai/rekordbox_pdb.ksy | 18 ++++++------- 10 files changed, 157 insertions(+), 39 deletions(-) create mode 100644 .github/resources/preview_notes.md create mode 100644 .github/resources/release_notes.md create mode 100644 .github/scripts/create_release.sh create mode 100644 .github/scripts/delete_preview.sh create mode 100644 .github/scripts/finish_release.sh diff --git a/.github/resources/preview_notes.md b/.github/resources/preview_notes.md new file mode 100644 index 0000000..eac2ac2 --- /dev/null +++ b/.github/resources/preview_notes.md @@ -0,0 +1,3 @@ +:construction: This is pre-release code for people who want to help test [what is going into the next release](https://github.com/Deep-Symmetry/crate-digger/blob/master/CHANGELOG.md). + +> Don’t download this if you aren’t comfortable testing code while it is under active development! Instead, look at the [latest release](https:///github.com/Deep-Symmetry/crate-digger/releases/latest). diff --git a/.github/resources/release_notes.md b/.github/resources/release_notes.md new file mode 100644 index 0000000..8703ee3 --- /dev/null +++ b/.github/resources/release_notes.md @@ -0,0 +1,3 @@ +## What’s in the Release + +✨Summary to be added once James has a moment! Please see the [Change Log](https://github.com/Deep-Symmetry/crate-digger/blob/main/CHANGELOG.md#LINK-GOES-HERE) for all the details. diff --git a/.github/scripts/create_release.sh b/.github/scripts/create_release.sh new file mode 100644 index 0000000..8e0dd72 --- /dev/null +++ b/.github/scripts/create_release.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e # Exit if any command fails. + +# See if we are creating a preview release +if [ "$release_snapshot" = true ] ; then + + # Create (or move) the latest-preview tag locally, then push it. + echo "Creating tag for preview release" + git config --global user.name 'James Elliott' + git config --global user.email 'james@deepsymmetry.org' + git tag latest-preview -m "The latest preview release" --force + git push --tags + + # Actually create the preview release and upload the cross-platform Jar + echo "Creating preview release" + gh release create latest-preview "$artifact_name#Library Jar" --prerelease \ + --title "Preview release being built" \ + --notes ":construction: This release is currently being built by GitHub Actions. Come back in a few minutes." + +else + + # Actually create the release and upload the cross-platform Jar + echo "Creating final release" + gh release create "$release_tag" "$artifact_name#Library Jar" --prerelease \ + --title "Release being built" \ + --notes ":construction: This release is currently being built by GitHub Actions. Come back in a few minutes." + +fi diff --git a/.github/scripts/delete_preview.sh b/.github/scripts/delete_preview.sh new file mode 100644 index 0000000..2d654e0 --- /dev/null +++ b/.github/scripts/delete_preview.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e # Exit if any command fails. + +# Check if the preview release exists. +if gh release view latest-preview --json assets --jq '.assets[].name' > preview_assets.txt ; then + + echo "There is a preview release. Deleting assets..." + while read -r asset; do + echo " Deleting asset $asset:" + gh release delete-asset latest-preview "$asset" --yes + done _header.md ; then + + # Extract the release date from that heading so we can build a link to the release notes. + rel_date=`sed 's/.* - //' <_header.md` + link="#${git_version//\./}---$rel_date" + + # Update the release note template to use the correct link + sed "s/#LINK-GOES-HERE/$link/" .github/resources/release_notes.md > _release_notes.md + + else + + # Log a workflow warning reporting that this release could not be found in the change log. + echo "::warning file=CHANGELOG.md,title=Unable to link from release notes.::No heading for release $git_version found" + + # Update the release note template to link to the top of the file + sed "s/#LINK-GOES-HERE//" .github/resources/release_notes.md > _release_notes.md + + fi + + # Update the release information on GitHub and reflect that it is ready. + gh release edit "$release_tag" --prerelease=false --latest --title "$release_tag" --notes-file _release_notes.md + + # Clean up our temporary files + rm -f _header.md + rm -f _release_notes.md + +fi diff --git a/.github/workflows/jar.yml b/.github/workflows/jar.yml index f7c4e36..bab7b4d 100644 --- a/.github/workflows/jar.yml +++ b/.github/workflows/jar.yml @@ -6,12 +6,7 @@ on: - main env: - initial_description: | - :construction: This is pre-release code for people who want to help test [what is going into the next release](https://github.com/Deep-Symmetry/crate-digger/blob/master/CHANGELOG.md). - - > Don’t download this if you aren’t comfortable testing code while it is under active development! Instead, look at the [latest release](https:///github.com/Deep-Symmetry/crate-digger/releases/latest). - - :calendar: **Ignore the “release date” above!** Because this is a snapshot release, the executables below (you may need to click to expand the Assets) will change frequently—whenever new code is pushed to the project—so you will want to _download the latest version every time you work with one_. The date you see _on each asset row_ shows you when it was last updated. Source code archive assets are not useful for snapshot releases, they will always reflect the state of the project when the snapshots began. + GH_TOKEN: ${{ github.token }} jobs: build_jar: @@ -24,6 +19,9 @@ jobs: uses: actions/checkout@v3 - name: Install SSH Key + env: + found_ssh_key: ${{ secrets.GUIDE_SSH_KEY }} + if: ${{ env.found_ssh_key != '' }} uses: shimataro/ssh-key-action@v2 with: key: ${{ secrets.GUIDE_SSH_KEY }} @@ -67,20 +65,20 @@ jobs: mvn package mv target/$built_name ./$artifact_name - - name: Upload library jar + - name: Delete any pre-existing preview release if: success() - uses: Xotl/cool-github-releases@v1 - with: - mode: update - tag_name: ${{ env.release_tag }} - release_name: ${{ env.release_name }} - isPrerelease: ${{ env.release_snapshot }} - replace_assets: ${{ env.release_snapshot }} - assets: ${{ env.artifact_name }} - github_token: ${{ github.token }} - initial_mrkdwn: ${{ env.initial_description }} + run: bash .github/scripts/delete_preview.sh + + - name: Create release and upload library jar + if: success() + run: bash .github/scripts/create_release.sh - name: Publish the JavaDoc + if: success() env: GUIDE_SSH_KEY: ${{ secrets.GUIDE_SSH_KEY }} run: bash .github/scripts/deploy_docs.sh + + - name: Update release title, description, and status + if: success() + run: bash .github/scripts/finish_release.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e129f3..ae73984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,30 @@ This change log follows the conventions of ## [Unreleased][unreleased] -Nothing so far. +### Changed + +- Upgraded Kaitai Struct to version 0.10, which includes a number of + fixes and adds linting of mapped values. + > :wrench: This is a backwards-incompatible change. +- Since we are already backwards incompatible with pervious releases, + changed some mapped value names to correspond to + the KSY style guide and fix linter errors reported by KSC 0.10: + 1. In `rekordbox_pdb.ksy` renamed `num_groups` to `num_row_groups`. + This means that `Page.numGroups` is now `Page.numRowGroups` in + the generated Java class. + 2. In `rekordbox_pdb.ksy` renamed `autoload_hotcues` to `autoload_hot_cues`. + This means that `TrackRow.autoloadHotcues` is now + `TrackRow.autoloadHotCues` in the generated Java class. + 3. In `rekordbox_anlz.ksy` renamed `len_preview` to `len_data`. + This means that `WavePreviewTag.lenPreview` is now + `WavePreviewTag.lenData` in the generated Java class. + 4. In `rekordbox_anlz.ksy` renamed `len_beats` to `num_beats`. + This means that `BeatGridTag.lenBeats` is now + `BeatGridTag.numBeats` in the generated Java class. + 5. In `rekordbox_anlz.ksy` renamed `len_cues` to `num_cues`. + This means that `CueTag.lenCues` and `ExtendedCueTag.lenCues` are now + `CueTag.numCues` and `ExtendedCueTag.numCues` in the generated Java + classes. ## [0.1.6] - 2022-03-07 diff --git a/pom.xml b/pom.xml index 3412ffc..58287e6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.deepsymmetry crate-digger - 0.1.6 + 0.2.0-SNAPSHOT jar Crate Digger @@ -55,7 +55,7 @@ io.kaitai kaitai-struct-runtime - 0.9 + 0.10 @@ -193,8 +193,8 @@ kaitai-maven-plugin 0.1.6 - 0.9 - https://github.com/kaitai-io/kaitai_struct_compiler/releases/download/0.9/kaitai-struct-compiler-0.9.zip + 0.10 + https://github.com/kaitai-io/kaitai_struct_compiler/releases/download/0.10/kaitai-struct-compiler-0.10.zip src/main/kaitai org.deepsymmetry.cratedigger.pdb true diff --git a/src/main/kaitai/rekordbox_anlz.ksy b/src/main/kaitai/rekordbox_anlz.ksy index f2b783a..ccc1884 100644 --- a/src/main/kaitai/rekordbox_anlz.ksy +++ b/src/main/kaitai/rekordbox_anlz.ksy @@ -93,14 +93,14 @@ types: seq: - type: u4 - type: u4 # @flesniak says this is always 0x80000 - - id: len_beats + - id: num_beats type: u4 doc: | The number of beat entries which follow. - id: beats type: beat_grid_beat repeat: expr - repeat-expr: len_beats + repeat-expr: num_beats doc: The entries of the beat grid. beat_grid_beat: @@ -134,7 +134,7 @@ types: doc: | Identifies whether this tag stores ordinary or hot cues. - size: 2 - - id: len_cues + - id: num_cues type: u2 doc: | The length of the cue list. @@ -145,7 +145,7 @@ types: - id: cues type: cue_entry repeat: expr - repeat-expr: len_cues + repeat-expr: num_cues cue_entry: doc: | @@ -207,7 +207,7 @@ types: enum: cue_list_type doc: | Identifies whether this tag stores ordinary or hot cues. - - id: len_cues + - id: num_cues type: u2 doc: | The length of the cue comment list. @@ -215,7 +215,7 @@ types: - id: cues type: cue_extended_entry repeat: expr - repeat-expr: len_cues + repeat-expr: num_cues cue_extended_entry: doc: | @@ -329,7 +329,7 @@ types: Stores a waveform preview image suitable for display above the touch strip for jumping to a track position. seq: - - id: len_preview + - id: len_data type: u4 doc: | The length, in bytes, of the preview data itself. This is @@ -337,7 +337,7 @@ types: length of the tag. - type: u4 # This seems to always have the value 0x10000 - id: data - size: len_preview + size: len_data doc: | The actual bytes of the waveform preview. if: _parent.len_tag > _parent.len_header diff --git a/src/main/kaitai/rekordbox_pdb.ksy b/src/main/kaitai/rekordbox_pdb.ksy index 21c9f5a..7431162 100644 --- a/src/main/kaitai/rekordbox_pdb.ksy +++ b/src/main/kaitai/rekordbox_pdb.ksy @@ -70,7 +70,7 @@ seq: - id: next_unused_page type: u4 doc: | - @flesinak said: "Not used as any `empty_candidate`, points + @flesniak said: "Not used as any `empty_candidate`, points past the end of the file." - type: u4 - id: sequence @@ -240,7 +240,7 @@ types: index entries there are, but some of those may not be marked as present in the table due to deletion). -webide-parse-mode: eager - num_groups: + num_row_groups: value: '(num_rows - 1) / 16 + 1' doc: | The number of row groups that are present in the index. Each @@ -249,7 +249,7 @@ types: row_groups: type: 'row_group(_index)' repeat: expr - repeat-expr: num_groups + repeat-expr: num_row_groups doc: | The actual row groups making up the row index. Each group can hold up to sixteen rows. Non-data pages do not have @@ -286,7 +286,7 @@ types: rows: type: row_ref(_index) repeat: expr - repeat-expr: '(group_index < (_parent.num_groups - 1)) ? 16 : ((_parent.num_rows - 1) % 16 + 1)' + repeat-expr: '(group_index < (_parent.num_row_groups - 1)) ? 16 : ((_parent.num_rows - 1) % 16 + 1)' doc: | The row offsets in this group. @@ -370,7 +370,7 @@ types: - type: u4 - type: u1 doc: | - @flesniak says: "alwayx 0x03, maybe an unindexed empty string" + @flesniak says: "always 0x03, maybe an unindexed empty string" - id: ofs_name type: u1 doc: | @@ -742,14 +742,14 @@ types: type: device_sql_string pos: _parent.row_base + ofs_strings[1] doc: | - A string of unknown purpose, which @flesnik named. + A string of unknown purpose, which @flesniak named. -webide-parse-mode: eager unknown_string_2: type: device_sql_string pos: _parent.row_base + ofs_strings[2] doc: | A string of unknown purpose; @flesniak said "thought - tracknumber -> wrong!" + track number -> wrong!" unknown_string_3: type: device_sql_string pos: _parent.row_base + ofs_strings[3] @@ -769,7 +769,7 @@ types: type: device_sql_string pos: _parent.row_base + ofs_strings[5] doc: | - A string of unknown purpose, which @flesnik named. + A string of unknown purpose, which @flesniak named. -webide-parse-mode: eager kuvo_public: type: device_sql_string @@ -780,7 +780,7 @@ types: a single bit somewhere, to control whether the track information is visible on Kuvo. -webide-parse-mode: eager - autoload_hotcues: + autoload_hot_cues: type: device_sql_string pos: _parent.row_base + ofs_strings[7] doc: |