Skip to content

Commit

Permalink
Upgrade to KSC 0.10
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brunchboy committed Mar 3, 2024
1 parent 86ad492 commit b80a5d9
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .github/resources/preview_notes.md
Original file line number Diff line number Diff line change
@@ -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).
3 changes: 3 additions & 0 deletions .github/resources/release_notes.md
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 29 additions & 0 deletions .github/scripts/create_release.sh
Original file line number Diff line number Diff line change
@@ -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 '[email protected]'
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
21 changes: 21 additions & 0 deletions .github/scripts/delete_preview.sh
Original file line number Diff line number Diff line change
@@ -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 <preview_assets.txt

echo "Deleting the preview release itself:"
gh release delete latest-preview --cleanup-tag --yes

else
echo "No preview release found to clean up."
fi

rm -f preview_assets.txt
41 changes: 41 additions & 0 deletions .github/scripts/finish_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -e # Exit if any command fails.

# See if we are creating a preview release
if [ "$release_snapshot" = true ] ; then

# Update the release information on GitHub and reflect that it is ready.
gh release edit latest-preview --title "$release_tag preview" --notes-file .github/resources/preview_notes.md

else

# Look for the heading in the change log corresponding to this version
pattern="^## \\[${git_version//\./\\.}\\]"
if grep "$pattern" CHANGELOG.md >_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
32 changes: 15 additions & 17 deletions .github/workflows/jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.deepsymmetry</groupId>
<artifactId>crate-digger</artifactId>
<version>0.1.6</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Crate Digger</name>
Expand Down Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>io.kaitai</groupId>
<artifactId>kaitai-struct-runtime</artifactId>
<version>0.9</version>
<version>0.10</version>
</dependency>

<!-- Remote Tea -->
Expand Down Expand Up @@ -193,8 +193,8 @@
<artifactId>kaitai-maven-plugin</artifactId>
<version>0.1.6</version>
<configuration>
<version>0.9</version>
<url>https://github.com/kaitai-io/kaitai_struct_compiler/releases/download/0.9/kaitai-struct-compiler-0.9.zip</url>
<version>0.10</version>
<url>https://github.com/kaitai-io/kaitai_struct_compiler/releases/download/0.10/kaitai-struct-compiler-0.10.zip</url>
<sourceDirectory>src/main/kaitai</sourceDirectory>
<packageName>org.deepsymmetry.cratedigger.pdb</packageName>
<overwrite>true</overwrite>
Expand Down
16 changes: 8 additions & 8 deletions src/main/kaitai/rekordbox_anlz.ksy
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -145,7 +145,7 @@ types:
- id: cues
type: cue_entry
repeat: expr
repeat-expr: len_cues
repeat-expr: num_cues

cue_entry:
doc: |
Expand Down Expand Up @@ -207,15 +207,15 @@ 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.
- size: 2
- id: cues
type: cue_extended_entry
repeat: expr
repeat-expr: len_cues
repeat-expr: num_cues

cue_extended_entry:
doc: |
Expand Down Expand Up @@ -329,15 +329,15 @@ 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
slightly redundant because it can be computed from the
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
Expand Down
18 changes: 9 additions & 9 deletions src/main/kaitai/rekordbox_pdb.ksy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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: |
Expand Down

0 comments on commit b80a5d9

Please sign in to comment.