Skip to content

Commit

Permalink
Update release instructions (#12)
Browse files Browse the repository at this point in the history
Made release instructions clearer and change the "release" tag to happen after the release PR has been merged to `main`. This (along with the following) ensures that this PR isn't included in the release notes of the next *framework* release.

Added a workflow to publish a release on tags of the form `x.y.z` (i.e. for release of the Swift package). This means that we'll have releases both when we publish framework and package (the former now has "(framework)" appended to its release name). This workflow cannot be tested before it's been merged to `main`, but a `workflow_dispatch` trigger has been added in case we need to debug.

The old releases have already been updated to conform to the changes in this PR.

The indentation in the workflow files has been adjusted for consistency.

In the "Publish Binary Framework" workflow the `zip` command was replaced with `ditto` as that is recommended in various places because it's the command that Finder uses to compress. It apparently also includes things that `zip` doesn't which could be relevant if the contents were to be signed at some point...

Finally, the generated swift file was also renamed to `generated.swift` to prevent it from confusing reviewers to think that it's manual work 🙈
  • Loading branch information
bisgardo authored Apr 25, 2024
1 parent 8e72580 commit 13dd10c
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 83 deletions.
84 changes: 42 additions & 42 deletions .github/workflows/lint+test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,50 @@ jobs:
strategy:
matrix:
runner:
- macos-11
- macos-12
- macos-13
- macos-14
- ubuntu-latest
- windows-latest
- macos-11 # X64
- macos-12 # X64
- macos-13 # X64
- macos-14 # ARM64
- ubuntu-latest
- windows-latest
rust-version:
- "1.72"
- "1.72"

runs-on: "${{matrix.runner}}"

steps:
# TODO: Consider adding caching.
- name: Setup Rust
run: |
rustup default "${{matrix.rust-version}}"
rustup component add rustfmt clippy
- name: Check out sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Check formatting
run: cargo fmt --check
- name: Run linter
run: cargo clippy --all-targets --all-features -- -Dwarnings
- name: Run tests
run: cargo test
- name: Build Swift package (macOS/x86_64 only)
if: runner.os == 'macOS' && runner.arch == 'X64'
run: |
make swift-bindings lib-darwin-x86_64 # produces './generated/bindings' and './target/x86_64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a'
xcodebuild -create-xcframework \
-library ./target/x86_64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a -headers ./generated/bindings \
-output ./generated/ConcordiumWalletCryptoUniffi.xcframework
- name: Build Swift package (macOS/arm64 only)
if: runner.os == 'macOS' && runner.arch == 'ARM64'
run: |
make swift-bindings lib-darwin-aarch64 # produces './generated/bindings' and './target/aarch64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a'
xcodebuild -create-xcframework \
-library ./target/aarch64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a -headers ./generated/bindings \
-output ./generated/ConcordiumWalletCryptoUniffi.xcframework
- name: Verify that library builds (macOS only)
if: runner.os == 'macOS'
run: swift build
env:
# Use the local framework built in previous step.
CONCORDIUM_WALLET_CRYPTO_FRAMEWORK_PATH: ./generated/ConcordiumWalletCryptoUniffi.xcframework
# TODO: Consider adding caching.
- name: Setup Rust
run: |
rustup default "${{matrix.rust-version}}"
rustup component add rustfmt clippy
- name: Check out sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Check formatting
run: cargo fmt --check
- name: Run linter
run: cargo clippy --all-targets --all-features -- -Dwarnings
- name: Run tests
run: cargo test
- name: Build Swift package (macOS/x86_64 only)
if: runner.os == 'macOS' && runner.arch == 'X64'
run: |
make swift-bindings lib-darwin-x86_64 # produces './generated/bindings' and './target/x86_64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a'
xcodebuild -create-xcframework \
-library ./target/x86_64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a -headers ./generated/bindings \
-output ./generated/ConcordiumWalletCryptoUniffi.xcframework
- name: Build Swift package (macOS/arm64 only)
if: runner.os == 'macOS' && runner.arch == 'ARM64'
run: |
make swift-bindings lib-darwin-aarch64 # produces './generated/bindings' and './target/aarch64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a'
xcodebuild -create-xcframework \
-library ./target/aarch64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a -headers ./generated/bindings \
-output ./generated/ConcordiumWalletCryptoUniffi.xcframework
- name: Verify that library builds (macOS only)
if: runner.os == 'macOS'
run: swift build
env:
# Use the local framework built in previous step.
CONCORDIUM_WALLET_CRYPTO_FRAMEWORK_PATH: ./generated/ConcordiumWalletCryptoUniffi.xcframework
46 changes: 23 additions & 23 deletions .github/workflows/publish-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ on:
required: true

env:
rust_version: "1.72"
rust_version: '1.72'

jobs:
build_publish:
runs-on: macos-13
runs-on: macos-latest

steps:
- name: Check out sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Rust
run: make setup
- name: Build binary framework
run: make framework # produces './generated/ConcordiumWalletCryptoUniffi.xcframework'
- name: Archive framework
working-directory: ./generated
run: |
zip -r ./ConcordiumWalletCryptoUniffi.xcframework.zip ./ConcordiumWalletCryptoUniffi.xcframework
swift package compute-checksum ./ConcordiumWalletCryptoUniffi.xcframework.zip > ./CHECKSUM
- name: Upload package as GitHub release
uses: softprops/action-gh-release@v1
with:
files: |
./generated/ConcordiumWalletCryptoUniffi.xcframework.zip
./generated/CHECKSUM
name: '${{github.event.inputs.version}}'
generate_release_notes: true
- name: Check out sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Rust
run: make setup
- name: Build binary framework
run: make framework # produces './generated/ConcordiumWalletCryptoUniffi.xcframework'
- name: Archive framework
working-directory: ./generated
run: |
ditto -c -k --sequesterRsrc --keepParent ./ConcordiumWalletCryptoUniffi.xcframework ./ConcordiumWalletCryptoUniffi.xcframework.zip
swift package compute-checksum ./ConcordiumWalletCryptoUniffi.xcframework.zip > ./CHECKSUM
- name: Upload package as GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
./generated/ConcordiumWalletCryptoUniffi.xcframework.zip
./generated/CHECKSUM
name: '${{github.event.inputs.version}} (framework)'
generate_release_notes: true
42 changes: 42 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish release for SwiftPM package tag

on:
push:
tags: "*.*.*"
workflow_dispatch: # trigger manually (for debugging)

jobs:
publish-release:
runs-on: ubuntu-latest

steps:
- name: Checkout project
uses: actions/checkout@v4
with:
ref: '${{github.ref}}'
- name: Extract version of the crate
uses: bisgardo/github-action-echo@v1
id: crate-version
with:
version: |
$(cargo metadata --format-version=1 | jq -r '.packages[] | select(.name == "concordium-wallet-crypto-uniffi") | .version')
- name: Fail if tag doesn't match crate version
if: "steps.crate-version.version != github.ref"
run: exit 1
- name: Extract tag message
uses: bisgardo/github-action-echo@v1
id: tag-msg
with:
msg: '$(git for-each-ref "${{github.ref}}" --format="%(contents)")'
- name: Fail if tag is not "annotated" or its message is empty
if: "steps.tag-msg.outputs.msg == ''"
run: exit 1
- name: Upload package as GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: '${{github.ref}}'
name: '${{github.ref}}'
# Release body is the message of the annotated tag.
body: |
${{steps.tag-msg.outputs.msg}}
generate_release_notes: false
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ swift-bindings: # produces './generated/bindings'
# Move Swift bridge code to source folder.
# The remaining files (header and renamed modulemap) should go into the framework
# (the directory is passed to 'xcodebuild -create-xcframework' via '-headers').
mv ./generated/bindings/crypto.swift ./Sources/ConcordiumWalletCrypto/crypto.swift
mv ./generated/bindings/crypto.swift ./Sources/ConcordiumWalletCrypto/generated.swift
mv ./generated/bindings/cryptoFFI.modulemap ./generated/bindings/module.modulemap

# BUILD STATIC LIBRARIES #
Expand Down
53 changes: 36 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,43 @@ which is explained in detail below.

## Release new version

The steps for building and releasing a new version `<version>` of the library are as follows:

1. Bump the version to `<version>` in `Cargo.toml` and insert the changelog header in a separate "release" PR.
2. Push a tag named `build/<version>-<build-version>` for the commit,
where `<build-version>` is bumped (starting from 0) for each attempt at building `<version>`.
This is necessary because GitHub requires releases to be tagged and the following workflow uploads a release.
3. Run the [workflow](./.github/workflows/publish-framework.yml) for publishing a new version of the binary framework.
Use the tag you just created as "branch" to run from and input `<version>` (i.e. without the counter for "Version").
4. Run `make swift-bindings` locally to regenerate the Swift bridge sources.
5. Update `Package.swift` with the updated `url` and `checksum` of the binary framework.
The workflow prints the checksum as the last step of its execution.
6. Commit the changes to `Sources/ConcordiumWalletCrypto/crypto.swift` and `Package.swift`
(no other files should have changes)
and push an annotated tag named by the version for the new commit:
Due to the dual nature of this repository, the release process is a little cumbersome,
so please follow the instructions below carefully.

The entire process should be done as a single PR (with no unrelated changes);
see [#11](https://github.com/Concordium/concordium-wallet-crypto-swift/pull/11) for a template.
To preserve tags, the PR must be merged without squashing.

Steps for building and releasing a new version `<version>` of the package:

1. Create and checkout a release branch named `release/<version>`.
2. Bump the version to `<version>` in `Cargo.toml` and
[insert the changelog header](https://github.com/Concordium/concordium-wallet-crypto-swift/pull/11/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed).
Commit and push the change to the release branch.
3. Create and push a (regular) tag named `build/<version>-<build-version>` for the new commit,
where `<build-version>` starts out at `0`.
Tagging is necessary because the workflow to be run in the next step uploads a release,
and GitHub requires releases to be tagged.
4. Run the [workflow](./.github/workflows/publish-framework.yml) for publishing a new version of the binary framework.
Use the tag you just created as "branch" to run from and input `<version>` (i.e. without the build number).
If the build fails, commit a fix to the branch and return to step 3 with `<build-version>` incremented by 1.
5. Run `make swift-bindings` locally to regenerate the Swift bridge sources.
6. Update `Package.swift` with the updated `url` and `checksum` of the binary framework.
The checksum is part of the release built by the workflow above as the file `CHECKSUM`.
7. Commit the changes to `Sources/ConcordiumWalletCrypto/generated.swift` and `Package.swift`
(no other files should have changes).
IMPORTANT: The generated Swift file is ignored by Git to prevent it from being updated untimely,
so it must be force added before committing:
```shell
git add -f ./Sources
```
8. Merge PR for release branch *without squashing*.
9. On the resulting *merge commit* into `main`, push an *annotated* tag named by the version:
```shell
git tag -a <version>
```
Give the tag a message describing what changed in the new version.
Give a brief description of the changes from the Swift perspective as the tag message.

The entire process should be done as a single PR which,
in order to preserve the tags, gets merged without squashing.
The pushing of this tag will trigger a special workflow to add a release for this tag.
The reason that the tag has to be after the merge is to avoid the release PR from being included in the autogenerated release notes
of the *next* (framework) release.
3 changes: 3 additions & 0 deletions Sources/ConcordiumWalletCrypto/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The generated swift file is ignored by default to prevent committing it untimely.
# Use 'git add -f ./Sources' to bypass this protection when releasing.
generated.swift
File renamed without changes.

0 comments on commit 13dd10c

Please sign in to comment.