Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 191 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Bump Version

on:
workflow_dispatch:
inputs:
version:
description: 'Version to bump to (e.g., 1.4.2)'
required: true
type: string

permissions:
contents: write

env:
CARGO_TERM_COLOR: always

jobs:
bump:
name: Bump version and create RC
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Update Cargo.toml with new version
run: |
VERSION="${{ inputs.version }}"
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml

# Update Cargo.lock
cargo update --workspace

- name: Commit version bump
id: commit
run: |
VERSION="${{ inputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git add Cargo.toml Cargo.lock
git commit -m "Bump version to v${VERSION}"
git push origin master

# Get the commit SHA
COMMIT_SHA=$(git rev-parse HEAD)
echo "sha=$COMMIT_SHA" >> $GITHUB_OUTPUT

build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: [bump]
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: skillfile-x86_64-linux
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: skillfile-aarch64-linux
cross: true
- target: x86_64-apple-darwin
os: macos-latest
artifact: skillfile-x86_64-macos
- target: aarch64-apple-darwin
os: macos-latest
artifact: skillfile-aarch64-macos
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact: skillfile-x86_64-windows.exe
steps:
- uses: actions/checkout@v4
with:
ref: master

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross (Linux aarch64)
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross

- name: Build release binary
shell: bash
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi

- name: Package artifact
shell: bash
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/skillfile${{ runner.os == 'Windows' && '.exe' || '' }} dist/${{ matrix.artifact }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}

create-rc:
name: Create RC Pre-release
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: Create checksums
working-directory: dist
run: sha256sum skillfile-* > checksums-sha256.txt

- name: Update flake.nix with new version and hashes
run: |
VERSION="${{ inputs.version }}"

# Read hashes from checksums file
X86_64_LINUX=$(grep "skillfile-x86_64-linux$" dist/checksums-sha256.txt | awk '{print $1}')
AARCH64_LINUX=$(grep "skillfile-aarch64-linux$" dist/checksums-sha256.txt | awk '{print $1}')
X86_64_DARWIN=$(grep "skillfile-x86_64-macos$" dist/checksums-sha256.txt | awk '{print $1}')
AARCH64_DARWIN=$(grep "skillfile-aarch64-macos$" dist/checksums-sha256.txt | awk '{print $1}')

# Update flake.nix with new version and hashes
sed -i \
-e "s/version = \"[^\"]*\";/version = \"$VERSION\";/" \
-e "s/x86_64-linux = \"[^\"]*\";/x86_64-linux = \"$X86_64_LINUX\";/" \
-e "s/aarch64-linux = \"[^\"]*\";/aarch64-linux = \"$AARCH64_LINUX\";/" \
-e "s/x86_64-darwin = \"[^\"]*\";/x86_64-darwin = \"$X86_64_DARWIN\";/" \
-e "s/aarch64-darwin = \"[^\"]*\";/aarch64-darwin = \"$AARCH64_DARWIN\";/" \
flake.nix

- name: Commit flake.nix update and create RC tag
run: |
VERSION="${{ inputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Pull latest master
git pull origin master

# Commit flake.nix if there are changes
if ! git diff --quiet flake.nix; then
git add flake.nix
git commit -m "Update flake.nix to v${VERSION}"
git push origin master
fi

# Now create and push the RC tag (points to the flake.nix update commit)
git tag "v${VERSION}-rc"
git push origin "v${VERSION}-rc"

- name: Extract changelog for this version
id: changelog
run: |
VERSION="${{ inputs.version }}"
# Extract the section between the first ## and the next ## (or EOF)
if [ -f CHANGELOG.md ]; then
awk '/^## v'"$VERSION"'/{found=1; next} found && /^## /{exit} found{print}' CHANGELOG.md > release-notes.md
else
echo "Release candidate for version ${VERSION}" > release-notes.md
fi

- name: Create RC pre-release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ inputs.version }}-rc
name: v${{ inputs.version }}-rc
body_path: release-notes.md
prerelease: true
files: |
dist/skillfile-*
dist/checksums-sha256.txt
install.sh
128 changes: 49 additions & 79 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
push:
tags: ["v*"]
tags: ["v*-rc"]

permissions:
contents: write
Expand All @@ -19,6 +19,7 @@ jobs:
verify-install:
name: Verify install script (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [ci]
timeout-minutes: 5
strategy:
fail-fast: false
Expand All @@ -38,67 +39,10 @@ jobs:
"${{ runner.temp }}/skillfile-test/skillfile" --version
"${{ runner.temp }}/skillfile-test/skillfile" --help

build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: [ci, verify-install]
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: skillfile-x86_64-linux
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: skillfile-aarch64-linux
cross: true
- target: x86_64-apple-darwin
os: macos-latest
artifact: skillfile-x86_64-macos
- target: aarch64-apple-darwin
os: macos-latest
artifact: skillfile-aarch64-macos
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact: skillfile-x86_64-windows.exe
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross (Linux aarch64)
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross

- name: Build release binary
shell: bash
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi

- name: Package artifact
shell: bash
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/skillfile${{ runner.os == 'Windows' && '.exe' || '' }} dist/${{ matrix.artifact }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}

publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: [build]
needs: [ci, verify-install]
steps:
- uses: actions/checkout@v4

Expand All @@ -118,34 +62,60 @@ jobs:
cargo publish -p skillfile

release:
name: Create GitHub Release
name: Promote RC to Release
runs-on: ubuntu-latest
needs: [build, publish]
needs: [publish]
steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create checksums
working-directory: dist
run: sha256sum skillfile-* > checksums-sha256.txt
- name: Download binaries from RC pre-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RC_TAG="${GITHUB_REF_NAME}"

# Download all assets from the RC pre-release
mkdir -p dist
gh release download "$RC_TAG" -D dist

- name: Extract changelog for this version
id: changelog
run: |
# Extract the section between the first ## and the next ## (or EOF)
# Remove -rc suffix to get the actual version
VERSION="${GITHUB_REF_NAME#v}"
awk '/^## v'"$VERSION"'/{found=1; next} found && /^## /{exit} found{print}' CHANGELOG.md > release-notes.md
VERSION="${VERSION%-rc}"

- name: Create release
uses: softprops/action-gh-release@v2
with:
body_path: release-notes.md
files: |
dist/skillfile-*
dist/checksums-sha256.txt
install.sh
if [ -f CHANGELOG.md ]; then
awk '/^## v'"$VERSION"'/{found=1; next} found && /^## /{exit} found{print}' CHANGELOG.md > release-notes.md
else
echo "Release version ${VERSION}" > release-notes.md
fi

- name: Create release tag and promote to full release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RC_TAG="${GITHUB_REF_NAME}"
VERSION="${RC_TAG#v}"
VERSION="${VERSION%-rc}"
RELEASE_TAG="v${VERSION}"

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Create the release tag pointing to the same commit as the RC tag
git tag "$RELEASE_TAG"
git push origin "$RELEASE_TAG"

# Create a new full release with the same assets
gh release create "$RELEASE_TAG" \
--title "$RELEASE_TAG" \
--notes-file release-notes.md \
dist/*

# Delete the RC pre-release and tag
gh release delete "$RC_TAG" --yes
git push --delete origin "$RC_TAG"
Loading