Skip to content

Commit

Permalink
Set up as a gem
Browse files Browse the repository at this point in the history
  • Loading branch information
cheshire137 committed Jan 19, 2025
1 parent 6f4cabc commit 518c32b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 4 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build_gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build gem

on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
release_tag:
description: "Release tag"
required: true

permissions:
contents: write

jobs:
build-gem:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ruby

- name: Get tag
id: get-tag
run: echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Install dependencies
run: bundle install

- name: Build gem
run: gem build good_audible_story_sync.gemspec -o good-audible-story-sync-${SOURCE_TAG}.gem
env:
SOURCE_TAG: ${{ env.SOURCE_TAG }}

- name: Create release
uses: softprops/action-gh-release@v2
with:
files: good-audible-story-sync-${SOURCE_TAG}.gem
tag_name: ${{ github.event.inputs.release_tag }}
token: ${{ secrets.GITHUB_TOKEN }}
env:
SOURCE_TAG: ${{ env.SOURCE_TAG }}
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ Script to sync your read books from Audible to Goodreads and StoryGraph.

## How to use

This is intended to be run from macOS.
> [!NOTE]
> This is intended to be run from macOS.
Download the [latest release](https://github.com/cheshire137/good-audible-story-sync/releases/latest) of the gem. Install it via:

```sh
bin/good-audible-story-sync
gem install good-audible-story-sync.gem
```

There should now be a `good-audible-story-sync` executable in your path. Run it via:

```sh
good-audible-story-sync
```

You will be prompted to log in to Audible and Storygraph. The tool saves your encrypted login
Expand All @@ -22,7 +31,7 @@ you finished reading and when.
### Options

```sh
Usage: bin/good-audible-story-sync [options]
Usage: good-audible-story-sync [options]
-d DATABASE_FILE, Path to Sqlite database file. Defaults to good_audible_story_sync.db.
--database-file
-e EXPIRATION_DAYS, Max number of days to use cached data, such as Audible library, before refreshing. Defaults to 1.
Expand All @@ -32,7 +41,7 @@ Usage: bin/good-audible-story-sync [options]
### Sample output

```sh
% bin/good-audible-story-sync
% good-audible-story-sync
🔐 Looking for 'good_audible_story_sync_encryption_key' in cheshire137's keychain...
ℹ️ Using GoodAudibleStorySync encryption key from keychain
⚙️ Parsing options...
Expand All @@ -59,6 +68,29 @@ bin/good-audible-story-sync
Run `srb tc` to run the [Sorbet type checker](https://sorbet.org/).
### Creating a tag
Update `VERSION` in [version.rb](./lib/good_audible_story_sync/version.rb).
```sh
git tag v0.0.x main # use the same version string as in `VERSION`
git push origin tag v0.0.x
```
This will trigger a workflow that builds the gem and creates a new release.
### Building the gem
```sh
gem build good_audible_story_sync.gemspec
```
This will create a file like project_pull_mover-0.0.1.gem which you can then install:
```sh
gem install good_audible_story_sync-0.0.1.gem
```
## Thanks
- [mkb79's Python Audible library](https://github.com/mkb79/Audible) for providing an example of how to authenticate with Audible and use its API, including the [unofficial API docs](https://audible.readthedocs.io/en/master/misc/external_api.html).
Expand Down
16 changes: 16 additions & 0 deletions good_audible_story_sync.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require_relative "lib/good_audible_story_sync/version"

Gem::Specification.new do |s|
s.name = "good_audible_story_sync"
s.version = GoodAudibleStorySync::VERSION
s.summary = "Command-line tool to sync your read books from Audible to Storygraph and, eventually, Goodreads."
s.description = "Interactive script to mark books as finished as well as set the finish date on Storygraph, based on your Audible activity."
s.authors = ["Sarah Vessels"]
s.email = "cheshire137@gmail.com"
s.files = Dir['lib/**/*'] + %w[LICENSE README.md]
s.bindir = "bin"
s.require_paths = ["lib"]
s.executables = ["good-audible-story-sync"]
s.homepage = "https://github.com/cheshire137/good-audible-story-sync"
s.license = "MIT"
end
6 changes: 6 additions & 0 deletions lib/good_audible_story_sync/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# typed: strict
# frozen_string_literal: true

module GoodAudibleStorySync
VERSION = "0.0.1"
end

0 comments on commit 518c32b

Please sign in to comment.