21 Commits

Author SHA1 Message Date
f583dac944 Update version to v0.1.6 2024-10-07 14:49:17 -05:00
dbfad44a51 Add schedule for workflow test 2024-10-07 14:43:02 -05:00
a636c6301a Mark TODO for pre-commit hook 2024-10-07 14:42:50 -05:00
30d135a4dc rename other workflows to lowercase 2024-10-07 14:32:22 -05:00
62fb74a153 Add testing badge, update changelog 2024-10-07 14:28:02 -05:00
c3e15fd9a5 Disable workflow_dispatch fail_fast input 2024-10-07 14:27:51 -05:00
0cc92b8978 Add optional artifact step for ubuntu build, fix fail_fast evaluation for non-dispatch 2024-10-07 14:25:15 -05:00
2e15d81dc9 Remove x86_64-unknown-linux-musl target runner detail, use defaults 2024-10-07 14:12:25 -05:00
28faf71583 Fix typo in name, simplify fail-fast evaluation 2024-10-07 14:12:06 -05:00
9ef2aac601 Add testing workflow (every push) 2024-10-07 13:59:33 -05:00
7e7af5920b lowercase the build workflow name 2024-10-07 13:52:13 -05:00
978b0ab264 Add CHANGELOG.md 2024-10-07 13:44:00 -05:00
a4568b2e72 Update README.md 2024-10-07 13:38:56 -05:00
7eaea3e2f4 Switch build pipeline to MSRV 1.74 2024-10-07 13:38:47 -05:00
22606aad30 Fix pre-commit.sh hook 2024-10-07 13:28:47 -05:00
70fd9da886 Update to 0.1.5 2024-10-06 16:17:33 -05:00
50de07ef28 Fix version tag regex 2024-10-06 16:17:29 -05:00
f8da0a647b Fix RELEASE_VERSION not being available for ARCHIVE variable, separate local/global variable sets 2024-10-06 16:16:07 -05:00
acf81f6bf6 Add pre-commit, pre-push hooks formally 2024-10-06 16:10:46 -05:00
2866c2fe4a Disable unnecessary notice of key length 2024-10-06 16:08:19 -05:00
98fc3c9902 Fix pkg-url, default to tgz explicit, v0.1.4 2024-10-06 16:07:14 -05:00
13 changed files with 265 additions and 29 deletions

View File

@@ -1,6 +1,3 @@
[target.x86_64-unknown-linux-musl]
runner = "musl-gcc"
[profile.release]
opt-level = "z"
strip = true

View File

@@ -1,4 +1,4 @@
name: Build
name: build
permissions:
contents: write
@@ -72,7 +72,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
toolchain: 1.74
targets: ${{ matrix.target }}
- name: Cache Rust dependencies
@@ -112,13 +112,19 @@ jobs:
- name: Prepare Variables
shell: bash
run: |
echo "RELEASE_VERSION=$(grep '^version = ' Cargo.toml | sed 's/version = \"\(.*\)\"/\1/')" >> $GITHUB_ENV
RELEASE_VERSION=$(grep '^version = ' Cargo.toml | sed 's/version = \"\(.*\)\"/\1/')
ARCHIVE=spotify-quickauth-v$RELEASE_VERSION-${{ matrix.target }}
if ${{ contains(matrix.os, 'windows') }}; then
echo "ARCHIVE=spotify-quickauth-v${{ env.RELEASE_VERSION }}-${{ matrix.target }}.zip" >> $GITHUB_ENV
ARCHIVE=$ARCHIVE.zip
else
echo "ARCHIVE=spotify-quickauth-v${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz" >> $GITHUB_ENV
ARCHIVE=$ARCHIVE.tar.gz
fi
echo "ARCHIVE_DIR=target/${{ matrix.target }}/release" >> $GITHUB_ENV
ARCHIVE_DIR=target/${{ matrix.target }}/release
# Export variables
echo "ARCHIVE_DIR=$ARCHIVE_DIR" >> $GITHUB_ENV
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- name: Archive
if: ${{ !contains(matrix.os, 'windows') }}
@@ -153,8 +159,6 @@ jobs:
ARCHIVE_PATH: ${{ env.ARCHIVE_DIR }}/${{ env.ARCHIVE }}
shell: bash
run: |
echo "::notice:: length = $(echo -n $MINISIGN_KEY | wc -c)"
echo "::notice:: length = $(echo -n "$MINISIGN_KEY" | wc -c)"
echo "$MINISIGN_KEY" > minisign.key
ts=$(node -e 'console.log((new Date).toISOString())')

View File

@@ -1,4 +1,4 @@
name: Integration
name: integration
on:
workflow_dispatch:

View File

@@ -1,4 +1,4 @@
name: GitHub Pages
name: github-pages
permissions:
pages: write

86
.github/workflows/test.yaml vendored Normal file
View File

@@ -0,0 +1,86 @@
name: test
on:
workflow_dispatch:
push:
paths-ignore:
- README.md
- .gitignore
- LICENSE
- run.sh
pull_request:
paths-ignore:
- README.md
- .gitignore
- LICENSE
- run.sh
schedule:
- cron: '30 14 * * 1' # every Monday, 9:30 AM CDT
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
tools: musl-tools
artifact: true
- os: macos-13
target: x86_64-apple-darwin
# - os: macos-latest
# target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
name: test-${{ matrix.os }}-${{ matrix.target }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.74
targets: ${{ matrix.target }}
- name: Install Linker Tools
if: matrix.tools
run: |
sudo apt-get update
sudo apt-get install ${{ matrix.tools }}
# ensure has a newline at the end
[ "$(tail -c 1 .cargo/config.toml)" != "" ] && echo >> .cargo/config.toml
cat .cargo/config.github.toml >> .cargo/config.toml
- name: Cache Rust dependencies
uses: actions/cache@v4.0.2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target
key: testing-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
testing-${{ runner.os }}-${{ matrix.target }}-
testing-${{ runner.os }}-
- name: Run tests
run: cargo test --verbose --target ${{ matrix.target }}
- name: Build
if: matrix.artifact
run: cargo build --verbose --target ${{ matrix.target }}
- name: Upload Artifact
if: matrix.artifact
uses: actions/upload-artifact@v4
with:
name: spotify-quickauth-${{ github.sha }}-${{ matrix.target }}
path: target/${{ matrix.target }}/debug/spotify-quickauth

10
.hooks/link.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
hooks=(
"pre-commit"
"pre-push"
)
for hook in "${hooks[@]}"; do
chmod +x .hooks/$hook.sh
ln -s -f ../../.hooks/$hook.sh .git/hooks/$hook
done

10
.hooks/pre-commit.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
# TODO: Only run when README.md is modified
# TODO: Support partial staging, where the 'Staged' version is copied to CARGO_README.md, and then `sed` is ran.
# Remove markdown extension lines for Cargo publishing
sed '/^>\[!/d' README.md > CARGO_README.md
# Add the modified file to the commit
git add CARGO_README.md

96
.hooks/pre-push.sh Executable file
View File

@@ -0,0 +1,96 @@
#!/bin/bash
# Script to be run as part of the github pre-push hook.
#
# Checks that, if there is a "version-like" tag being pushed, all the files which are supposed to contain the tag do
# actually have the correct tag value in them. If they do not, the push is blocked.
# NB: this does _not_ automatically alter the source files and commit them with the correct tag value, nor prevent the
# tag to be added to the wrong git commit locally (ie. a commit in which the source files have the wrong tag value).
# All it does is prevent the developer from pushing the 'bad tags' to remote repositories, giving him/her the chance to
# manually rectify the situation on the local repo before retrying to push.
#
# @todo could this be run as pre-commit hook instead? We have to test if adding a tag does trigger pre-commit hook...
# @see https://stackoverflow.com/questions/56538621/git-hook-to-check-tag-name
# @see https://stackoverflow.com/questions/8418071/is-there-a-way-to-check-that-a-git-tag-matches-the-content-of-the-corresponding
# for an alternative take (enforcing this with a server-side hook)
#
# NB: remember that this can be run within a windows env too, via fe. the tortoisegit or the git-4-win on the cli!
# git for windows comes with its own copy of common unix utils such as bash, grep. But they are sometimes old and/or
# buggy compared to what one gets in current linux distros :-(
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local oid> <remote ref> <remote oid>
# We do not abort the push in case there is an error in this script. No `set -e`
#set -e
# @todo detect if this is run outside git hook, and give a warning plus explain how to pass in $local_ref $local_oid $remote_ref $remote_oid
# @todo allow a git config parameter to switch on/off a 'verbose mode'
# @todo we could allow the variables `files` and `version_tag_regexp` to be set via git config parameters instead of hardcoded
# List of files which do contain the version tag
files='Cargo.toml'
# Regexp use to decide if a git tag is a version label
version_tag_regexp='^[0-9]{1,4}\.[0-9]{1,4}(\.[0-9]{1,4})?'
# Create a string of '0' chars of appropriate length for the current git version
zero="$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')"
echo "Checking commits for version tags before push..."
# check all commits which we are pushing
while read local_ref local_oid remote_ref remote_oid; do
#echo "Checking commit $local_oid ..."
# skip ref deletions
if [ "$local_oid" != "$zero" ]; then
#if [ "$remote_oid" = "$zero" ]; then
# # 'new branch'
# range="$local_oid"
#else
# # 'update to existing branch'
# range="$remote_oid..$local_oid"
#fi
# @todo in case we have a range (see commented out code 2 lines above), should we check more commits?
tags="$(git tag --points-at $local_oid)"
if [ -n "$tags" ]; then
# @todo this will not work predictably if there are 2 version tags attached to the same commit. Which probably
# there should not be anyway. Should we check for that too and abort in case?
while IFS= read -r tag; do
echo "Found tag: '$tag'..."
if [[ "$tag" =~ $version_tag_regexp ]]; then
echo "Tag looks like a version number. Checking if code is matching..."
for file in $files; do
if [ ! -f "$file" ]; then
echo "File is missing: '$file'. Please fix config of github hook script"
exit 2
fi
echo "Looking for '$tag' in '$file'"
# @todo atm if the version tag is f.e. v1.1, any file containing the string "clamav1.10' will
# match. We should improve this match to avoid such scenarios
# Note: we can not use `-i` as it crashes git-4-win's grep
if grep -F -q "$tag" "$file"; then
:
else
echo "Tag is missing from file '$file'"
exit 1
fi
done
echo "All files ok!"
break 2; # exit from both while loops: no need to check for further tags
fi
done <<< "$tags"
fi
fi
done
exit 0

View File

@@ -1,7 +1,11 @@
# spotify-quickauth
[![Build Status](https://github.com/Xevion/spotify-quickauth/workflows/Build/badge.svg)](https://github.com/Xevion/spotify-quickauth/actions)
[![Build Status](https://github.com/Xevion/spotify-quickauth/workflows/build/badge.svg)](https://github.com/Xevion/spotify-quickauth/actions)
[![Testing Status](https://github.com/Xevion/spotify-quickauth/workflows/test/badge.svg)](https://github.com/Xevion/spotify-quickauth/actions)
[![Crates.io](https://img.shields.io/crates/v/spotify-quickauth.svg)](https://crates.io/crates/spotify-quickauth)
![Crates.io MSRV](https://img.shields.io/crates/msrv/spotify-quickauth)
![GitHub last commit](https://img.shields.io/github/last-commit/Xevion/spotify-quickauth)
<!-- TODO: Add testing status badge -->
A simple CLI-based application for creating a `credentials.json` file, used by `librespot` derived applications, such as [spotify-player][spotify-player], [spotifyd][spotifyd], and [raspotify][raspotify].
@@ -10,8 +14,6 @@ A simple CLI-based application for creating a `credentials.json` file, used by `
- Automatically places configuration files
- No dependencies, no installation, no fuss
>This README is literally filled with lies. I'm not joking, I've just typed up a bunch of features I plan to implement, and am planning them out now. A fair amount of it works, but most of the specific options aren't currently implemented. I'm working on it, I promise!
## Quickstart
You can run this application without installing anything by using the following commands.
@@ -47,7 +49,7 @@ Installation is not necessary to use this application, but if you're having trou
### Pre-built Binaries
Binaries are always available for download from the [releases page][releases], and they're the same ones used by the shell scripts above.
Binaries are always available for download from the [releases page][latestRelease], and they're the same ones used by the shell scripts above.
Currently, the following targets are available for download:
- x64 Linux (MUSL) `x86_64-unknown-linux-musl`
@@ -58,14 +60,33 @@ Currently, the following targets are available for download:
- x64 Windows `x86_64-pc-windows-msvc`
- ARM64 Windows `aarch64-pc-windows-msvc`
Please [file an issue][new-issue] if you are on a platform that is not supported, or if you encounter issues with the binaries.
### Via `cargo-binstall`
> If the package cannot be found for your target or fails to be downloaded for any reason, `cargo-binstall` will automatically fall back to building the package from source.
`cargo-binstall` is a tool that allows you to install binaries from crates.io without needing to compile them yourself.
```
cargo binstall spotify-quickauth
```
If you're curious where the binary comes from, `cargo-binstall` will likely pull the binary directly from the [latest release][latestRelease] by this repository, selecting the most appropriate target for your host.
### Manual Installation
If you'd like to use the shell script above to install the binary, you can use the `-S/--stop` flag to prevent the script from running the binary after downloading it. It implicitly applies the `--keep` flag too.
You'll need to move the binary yourself though:
```bash
curl -sSL https://xevion.github.io/spotify-quickauth/run.sh | sh -s -- -S
mv spotify-quickauth /usr/local/bin
```
Then you can move it to whatever location you'd like. Make sure that directory is in your $PATH though!
Make sure your directory of choice is in your $PATH though!
### Building from Source
@@ -85,10 +106,13 @@ If you have any troubles building the project
- Make sure you're using a target that's supported by the project (see above).
- Certain targets may require specfic linkers. For example,
[latestRelease]: https://github.com/Xevion/spotify-quickauth/releases/latest/
[spotify-player]: https://github.com/aome510/spotify-player
[spotifyd]: https://github.com/Spotifyd/spotifyd
[raspotify]: https://github.com/dtcooper/raspotify
[rustup]: https://rustup.rs
[git]: https://git-scm.com
[binstall]: https://github.com/cargo-bins/cargo-binstall
[quickinstall]: https://github.com/cargo-bins/cargo-quickinstall
[quickinstall]: https://github.com/cargo-bins/cargo-quickinstall
[binstall-installation]: https://github.com/cargo-bins/cargo-binstall#installation
[new-issue]: https://github.com/Xevion/spotify-quickauth/issues/new

11
CHANGELOG.md Normal file
View File

@@ -0,0 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.
## v0.1.6
- Began tracking changes in the `CHANGELOG.md` file.
- [breaking] Lowered MSRV to 1.74 to match `librespot`'s `0.5.0-dev` branch.
- Fixed `pre-commit` hook to properly process the `CARGO_README.md` file.
- Added testing workflow to the repository, targeting only major x64 platforms.
- New testing badge in README

2
Cargo.lock generated
View File

@@ -1287,7 +1287,7 @@ dependencies = [
[[package]]
name = "spotify-quickauth"
version = "0.1.3"
version = "0.1.6"
dependencies = [
"env_logger",
"futures",

View File

@@ -1,9 +1,9 @@
[package]
name = "spotify-quickauth"
version = "0.1.3"
version = "0.1.6"
edition = "2021"
description = "Quickly authenticate librespot-based applications with Spotify"
rust-version = "1.81"
rust-version = "1.74"
authors = ["Ryan Walters <xevion@xevion.dev>"]
homepage = "https://github.com/Xevion/spotify-quickauth"
repository = "https://github.com/Xevion/spotify-quickauth"
@@ -11,7 +11,8 @@ license = "MIT OR Apache-2.0"
readme = "CARGO_README.md"
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/spotify-quickauth-v{ version }-{ target }-{ archive-suffix }"
pkg-url = "{ repo }/releases/download/v{ version }/spotify-quickauth-v{ version }-{ target }{ archive-suffix }"
pkg-format = "tgz"
[package.metadata.binstall.signing]
algorithm = "minisign"

View File

@@ -1,11 +1,11 @@
# spotify-quickauth
[![Build Status](https://github.com/Xevion/spotify-quickauth/workflows/Build/badge.svg)](https://github.com/Xevion/spotify-quickauth/actions)
<!-- TODO: Add testing status badge -->
[![Build Status](https://github.com/Xevion/spotify-quickauth/workflows/build/badge.svg)](https://github.com/Xevion/spotify-quickauth/actions)
[![Testing Status](https://github.com/Xevion/spotify-quickauth/workflows/test/badge.svg)](https://github.com/Xevion/spotify-quickauth/actions)
[![Crates.io](https://img.shields.io/crates/v/spotify-quickauth.svg)](https://crates.io/crates/spotify-quickauth)
![Crates.io MSRV](https://img.shields.io/crates/msrv/spotify-quickauth)
![GitHub last commit](https://img.shields.io/github/last-commit/Xevion/spotify-quickauth)
<!-- TODO: Add testing status badge -->
A simple CLI-based application for creating a `credentials.json` file, used by `librespot` derived applications, such as [spotify-player][spotify-player], [spotifyd][spotifyd], and [raspotify][raspotify].
@@ -14,9 +14,6 @@ A simple CLI-based application for creating a `credentials.json` file, used by `
- Automatically places configuration files
- No dependencies, no installation, no fuss
>[!WARNING]
>This README is literally filled with lies. I'm not joking, I've just typed up a bunch of features I plan to implement, and am planning them out now. A fair amount of it works, but most of the specific options aren't currently implemented. I'm working on it, I promise!
## Quickstart
You can run this application without installing anything by using the following commands.