2024-05-13 23:01:52 +02:00
|
|
|
name: Create Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
release_type:
|
|
|
|
description: 'Type of release to create'
|
|
|
|
required: true
|
|
|
|
default: 'minor'
|
|
|
|
type: choice
|
|
|
|
options:
|
|
|
|
- patch
|
|
|
|
- minor
|
|
|
|
- major
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
bump-version:
|
|
|
|
runs-on: ubuntu-latest
|
2024-05-17 19:34:59 +02:00
|
|
|
outputs:
|
|
|
|
new_version: ${{ steps.cargo-bump.outputs.new_version }}
|
2024-05-13 23:01:52 +02:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
2024-05-17 18:50:26 +02:00
|
|
|
- name: Run semver-diff
|
|
|
|
if: inputs.release_type == ''
|
|
|
|
id: semver-diff
|
|
|
|
uses: tj-actions/semver-diff@v3
|
|
|
|
with:
|
|
|
|
initial_release_type: ${{ inputs.release_type }}
|
|
|
|
- name: Install stable toolchain
|
|
|
|
if: steps.semver-diff.outputs.release_type != '' || inputs.release_type != ''
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
profile: minimal
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
2024-05-17 18:44:56 +02:00
|
|
|
- uses: actions/cache@v4
|
2024-05-17 18:50:26 +02:00
|
|
|
if: steps.semver-diff.outputs.release_type != '' || inputs.release_type != ''
|
2024-05-17 18:44:56 +02:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo/bin/
|
|
|
|
~/.cargo/registry/index/
|
|
|
|
~/.cargo/registry/cache/
|
|
|
|
~/.cargo/git/db/
|
|
|
|
key: ${{ runner.os }}-cargo-cargo-bump
|
2024-05-17 18:50:26 +02:00
|
|
|
- name: Bump Cargo.toml version
|
2024-05-17 19:34:59 +02:00
|
|
|
id: cargo-bump
|
2024-05-17 18:50:26 +02:00
|
|
|
shell: bash
|
|
|
|
if: steps.semver-diff.outputs.release_type != '' || inputs.release_type != ''
|
|
|
|
working-directory: '.'
|
|
|
|
run: |
|
2024-05-17 19:34:59 +02:00
|
|
|
if ! command -v cargo-bump &> /dev/null; then
|
|
|
|
cargo install cargo-bump --force
|
2024-05-17 18:50:26 +02:00
|
|
|
fi
|
2024-05-17 19:34:59 +02:00
|
|
|
cargo bump ${{ inputs.release_type }}
|
2024-05-17 18:50:26 +02:00
|
|
|
cargo update --workspace
|
2024-05-17 19:34:59 +02:00
|
|
|
echo "new_version=$(grep -m 1 -oP '(?<=version = ")[^"]+' Cargo.toml)" >> "$GITHUB_OUTPUT"
|
2024-05-13 23:01:52 +02:00
|
|
|
- name: Commit changes
|
|
|
|
uses: stefanzweifel/git-auto-commit-action@v4
|
|
|
|
with:
|
2024-05-17 19:34:59 +02:00
|
|
|
commit_message: "Bump version to v${{ steps.cargo-bump.outputs.new_version }}"
|
2024-05-13 23:01:52 +02:00
|
|
|
commit_user_name: "github-actions[bot]"
|
|
|
|
commit_user_email: "github-actions[bot]@users.noreply.github.com"
|
|
|
|
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
|
|
|
|
branch: master
|
|
|
|
- name: Create tag
|
|
|
|
uses: rickstaa/action-create-tag@v1
|
|
|
|
with:
|
2024-05-17 19:34:59 +02:00
|
|
|
tag: v${{ steps.cargo-bump.outputs.new_version }}
|
|
|
|
message: "Bump version to v${{ steps.cargo-bump.outputs.new_version }}"
|
|
|
|
|
|
|
|
release:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
needs: bump-version
|
|
|
|
steps:
|
|
|
|
- name: Checkout Code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
ref: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
- name: Update CHANGELOG
|
|
|
|
id: changelog
|
|
|
|
uses: requarks/changelog-action@v1
|
|
|
|
with:
|
|
|
|
token: ${{ github.token }}
|
|
|
|
tag: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
- name: Create Release
|
|
|
|
uses: ncipollo/release-action@v1
|
|
|
|
with:
|
|
|
|
allowUpdates: true
|
|
|
|
draft: false
|
|
|
|
makeLatest: true
|
|
|
|
name: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
body: ${{ steps.changelog.outputs.changes }}
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
tag: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
- name: Commit CHANGELOG.md
|
|
|
|
uses: stefanzweifel/git-auto-commit-action@v4
|
|
|
|
with:
|
|
|
|
branch: master
|
|
|
|
commit_message: 'docs: update CHANGELOG.md for v${{ needs.bump-version.outputs.new_version }} [skip ci]'
|
|
|
|
file_pattern: CHANGELOG.md
|
|
|
|
|
|
|
|
linux:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
needs:
|
|
|
|
- release
|
|
|
|
- bump-version
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
ref: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
- name: install Rust stable
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
cargo build --verbose --release
|
|
|
|
- name: Rename binary
|
|
|
|
run: |
|
|
|
|
mv target/release/spotify-dl target/release/spotify-dl.linux-x86_64
|
|
|
|
- name: Upload Linux Artifact
|
|
|
|
uses: ncipollo/release-action@v1
|
|
|
|
with:
|
|
|
|
allowUpdates: True
|
|
|
|
makeLatest: True
|
|
|
|
omitBody: True
|
|
|
|
omitBodyDuringUpdate: True
|
|
|
|
omitNameDuringUpdate: True
|
|
|
|
artifacts: target/release/spotify-dl.linux-x86_64
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
tag: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
|
|
|
|
macos:
|
|
|
|
runs-on: macos-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
needs:
|
|
|
|
- release
|
|
|
|
- bump-version
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
ref: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
- name: install Rust stable
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
cargo build --verbose --release
|
|
|
|
- name: Rename binary
|
|
|
|
run: |
|
|
|
|
mv target/release/spotify-dl target/release/spotify-dl.macos-aarch64
|
|
|
|
- name: Upload MacOS Artifact
|
|
|
|
uses: ncipollo/release-action@v1
|
|
|
|
with:
|
|
|
|
allowUpdates: True
|
|
|
|
makeLatest: True
|
|
|
|
omitBody: True
|
|
|
|
omitBodyDuringUpdate: True
|
|
|
|
omitNameDuringUpdate: True
|
|
|
|
artifacts: target/release/spotify-dl.macos-aarch64
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
tag: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
|
|
|
|
windows:
|
|
|
|
runs-on: windows-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
needs:
|
|
|
|
- release
|
|
|
|
- bump-version
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
ref: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
- name: install Rust stable
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
cargo build --verbose --release
|
|
|
|
- name: Rename binary
|
|
|
|
run: |
|
|
|
|
mv target/release/spotify-dl.exe target/release/spotify-dl.windows-x86_64
|
|
|
|
- name: Upload Windows Artifact
|
|
|
|
uses: ncipollo/release-action@v1
|
|
|
|
with:
|
|
|
|
allowUpdates: True
|
|
|
|
makeLatest: True
|
|
|
|
omitBody: True
|
|
|
|
omitBodyDuringUpdate: True
|
|
|
|
omitNameDuringUpdate: True
|
|
|
|
artifacts: target/release/spotify-dl.windows-x86_64
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
tag: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
|
|
|
|
cargo:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- bump-version
|
|
|
|
- release
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
ref: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
- name: install Rust stable
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
cargo build --verbose --release
|
|
|
|
- name: Run cargo publish
|
|
|
|
run: |
|
|
|
|
cargo publish --token ${{ secrets.CARGO_TOKEN }}
|
|
|
|
|
|
|
|
homebrew:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- bump-version
|
|
|
|
- release
|
|
|
|
steps:
|
|
|
|
- name: Update Hombrew formula
|
|
|
|
uses: dawidd6/action-homebrew-bump-formula@v3
|
|
|
|
with:
|
|
|
|
tap: guillemcastro/spotify-dl
|
|
|
|
formula: spotify-dl
|
|
|
|
token: ${{ secrets.HOMEBREW_TOKEN }}
|
|
|
|
tag: v${{ needs.bump-version.outputs.new_version }}
|
|
|
|
no_fork: true
|
|
|
|
|