diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4158938..ced7069 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: @@ -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 @@ -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/') \ No newline at end of file diff --git a/README.md b/README.md index 51a622e..5548c8e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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"} diff --git a/mix.exs b/mix.exs index 5a5067a..1511cfb 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule CSSInline.MixProject do use Mix.Project - @version "0.1.0" + @version "0.1.1" def project do [