Skip to content
Merged
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
25 changes: 18 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: Build precompiled NIFs

on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.0) - must match mix.exs'
required: true
type: string

permissions:
contents: write

jobs:
build_release:
Expand All @@ -28,11 +33,15 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v5

- name: Extract project version
- name: Validate version matches mix.exs
shell: bash
run: |
# Get the project version from mix.exs
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV
MIX_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)
if [ "$MIX_VERSION" != "${{ inputs.version }}" ]; then
echo "Error: Input version (${{ inputs.version }}) does not match mix.exs version ($MIX_VERSION)"
exit 1
fi
echo "PROJECT_VERSION=${{ inputs.version }}" >> $GITHUB_ENV

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.93.0
Expand All @@ -59,7 +68,9 @@ jobs:
- name: Publish archives and packages
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ inputs.version }}
name: v${{ inputs.version }}
draft: false
files: |
${{ steps.build-crate.outputs.file-path }}
if: startsWith(github.ref, 'refs/tags/')

21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,12 @@ Releasing a new version involves building precompiled NIFs and generating a chec

1. **Update the version** in `mix.exs` and create a PR to merge to `main`

2. **Create and push a tag** to trigger the build workflow:
```bash
git checkout main
git pull origin main
git tag vX.Y.Z
git push origin vX.Y.Z
```
2. **Manually trigger the build workflow**:
- Go to Actions → "Build precompiled NIFs" → "Run workflow"
- Enter the version (e.g., `0.1.0`) - must match `mix.exs`
- This builds all binaries and uploads them to a GitHub release

3. **Wait for GitHub Actions to complete** - the "Build precompiled NIFs" workflow will compile binaries for all targets and upload them to the GitHub release
3. **Wait for all builds to complete** - all targets must succeed before proceeding

4. **Generate the checksum file** locally:
```bash
Expand All @@ -104,14 +101,16 @@ Releasing a new version involves building precompiled NIFs and generating a chec

5. **Create a PR** with the generated `checksum-Elixir.CSSInline.Native.exs` file and merge to `main`

6. **Update the tag** to include the checksum commit:
6. **Create the tag** pointing to the commit with the checksum:
```bash
git checkout main
git pull origin main
git tag -f vX.Y.Z
git push origin vX.Y.Z --force
git tag vX.Y.Z
git push origin vX.Y.Z
```

> **Important**: The workflow is manually triggered (not on tag push) to prevent rebuilds when updating the tag. This ensures the checksum file matches the released artifacts.

Consumers can now use the release by pinning to the tag:
```elixir
{:css_inline, github: "knocklabs/css_inline", tag: "vX.Y.Z"}
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule CSSInline.MixProject do
use Mix.Project

@version "0.1.0"
@version "0.1.1"

def project do
[
Expand Down