Skip to content

Commit

Permalink
ci: publish to cloudsmith and cocoapods
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyBedard committed Jun 17, 2024
1 parent 63c7fe8 commit 98ba6d0
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 39 deletions.
232 changes: 200 additions & 32 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,221 @@
name: Publish Package

on:
push:
workflow_dispatch:
inputs:
beta:
description: Publish a beta version (npmjs)
default: false
required: true
type: boolean
rust:
description: Publish a rust version (crates.io)
default: true
required: true
type: boolean
android:
description: Publish an android version (maven)
default: true
required: true
type: boolean
wasm:
description: Publish a wasm version (npmjs)
default: true
required: true
type: boolean
swift:
description: Publish a swift version (cocoapods)
default: true
required: true
type: boolean

jobs:
npmjs:
environment: npm-publish
runs-on: ubuntu-latest
defaults:
run:
working-directory: wasm
# build-wasm:
# environment: npm-publish
# runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
# steps:
# - name: Checkout repo
# uses: actions/checkout@v4

# - name: Checkout action
# uses: actions/checkout@v3
# with:
# repository: Devolutions/actions
# path: actions
# ref: v2
# token: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}

# - name: Setup wasm
# run: |
# curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# wasm-pack --version

# - name: Build
# run: sh build.sh
# working-directory: wrappers/wasm

# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: wasm
# path: dist/bundler

# - name: Setup .npmrc config file
# uses: ./actions/npmrc-setup
# with:
# github_token: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}

# - name: Publish
# run: npm publish --tag 'beta' #${{ inputs.beta && 'beta' || 'latest' }}
# working-directory: dist/bundler

# - run: rm $HOME/.npmrc

# - name: Configure NPM
# run: npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"

# - name: Publish
# run: npm publish --tag 'beta' #${{ inputs.beta && 'beta' || 'latest' }}
# working-directory: dist/bundler

# # - name: Update Artifactory Cache
# # run: gh workflow run update-artifactory-cache.yml --repo Devolutions/scheduled-tasks --field package_name="slauth"
# # env:
# # GH_TOKEN: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}

# build-android:
# environment: cloudsmith-publish
# runs-on: ubuntu-latest

- name: Install dependencies
run: cargo install wasm-pack
working-directory: wasm
# steps:
# - name: Checkout repo
# uses: actions/checkout@v4

- name: Configure NPM
run: npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
# - name: Set up JDK 1.8
# uses: actions/setup-java@v4
# with:
# java-version: '8'
# distribution: 'adopt'

- name: Build
run: ./build.sh
working-directory: wasm
# - name: Setup Android
# run: |
# wget https://dl.google.com/android/repository/android-ndk-r23b-linux.zip
# unzip android-ndk-r23b-linux.zip
# export ANDROID_NDK_HOME=$GITHUB_WORKSPACE/android-ndk-r23b
# echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
# echo "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
# echo "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android" >> $GITHUB_ENV::LIBRARY_PATH
# echo "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android" >> $GITHUB_ENV::LD_LIBRARY_PATH
# rustup target add aarch64-linux-android
# rustup target add x86_64-linux-android
# rustup target add x86_64-unknown-linux-gnu

- name: Publish
run: npm publish --tag ${{ inputs.beta && 'beta' || 'latest' }}
working-directory: dist/bundler

- name: Update Artifactory Cache
run: gh workflow run update-artifactory-cache.yml --repo Devolutions/scheduled-tasks --field package_name="slauth"
env:
GH_TOKEN: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}
# - name: Build
# run: |
# cd wrappers/android
# sh build.sh

crates-io:
environment: crates-publish
runs-on: ubuntu-latest
# - name: Create local.properties
# run: |
# echo "sdk.dir=$ANDROID_HOME" > local.properties

# - run: chmod +x gradlew

# - name: Package .aar
# run: ./gradlew clean assembleRelease
# env:
# CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
# CLOUDSMITH_USERNAME: bot-devolutions

# - run: ./gradlew publish
# env:
# CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
# CLOUDSMITH_USERNAME: bot-devolutions

# - name: Upload .aar artifact
# uses: actions/upload-artifact@v4
# with:
# name: android
# path: wrappers/android/build/outputs/aar/slauth-release.aar

build-swift:
environment: cocoapods-publish
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v4

- name: Select Xcode Version
run: ls /Applications | grep Xcode

- run: xcodebuild -version

- run: |
rustup target add aarch64-apple-ios
rustup target add x86_64-apple-ios
- name: Build iOS libraries
run: sh wrappers/swift/build.sh

# - name: Move files
# run: |
# mv LICENSE target
# mv ./slauth.h target

# - name: Package binaries
# run: |
# tar -czvf Slauth.tar.gz target

# - name: Checkout action
# uses: actions/checkout@v4
# with:
# repository: Devolutions/actions
# path: actions
# ref: v1
# token: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}

# - name: Upload files to storage account
# uses: ./actions/azure-storage-blob-upload
# with:
# azure_client_id: ${{ secrets.DEVMANAGER_CLIENT_ID }}
# azure_client_secret: ${{ secrets.DEVMANAGER_CLIENT_SECRET }}
# azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
# container: download
# files: Slauth.tar.gz #'target/universal/release/libslauth_universal.a;target/x86_64-apple-ios/release/libslauth_x86.a;target/aarch64-apple-ios/release/libslauth_arm64.a;target/slauth.h'
# resource_group: cdndevolutions-prod
# storage_account: cdndevolutions

- run: pod spec lint

# - name: Update Podspec
# run: |
# sed -i '' "s|spec.source = { :git => '.*', :tag => s.version.to_s }|spec.source = { :http => 'URL_to_Slauth-${{ github.ref_name }}.tar.gz' }|g" Slauth.podspec

# build-rust:
# environment: crates-publish
# runs-on: ubuntu-latest

# steps:
# - name: Checkout repo
# uses: actions/checkout@v4

# - run: cargo package

# - name: Find package version
# id: package
# run: echo name=$(ls *.crate) > $GITHUB_OUTPUT
# working-directory: target/package

# - name: Upload Artifact
# uses: actions/upload-artifact@v4
# with:
# name: rust
# path: target/package/${{ steps.package.outputs.name }}

- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# - name: Publish
# run: cargo publish
# env:
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
8 changes: 4 additions & 4 deletions Slauth.podspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Pod::Spec.new do |s|
s.name = 'Slauth'
s.version = '0.7.6'
s.summary = 'A Swift wrapper aroud Slauth Rust crate'
s.summary = 'A Swift wrapper around Slauth Rust crate'
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC

s.homepage = 'https://github.com/Devolutions/Slauth.git'
s.license = { :type => 'MIT', :file => './LICENSE' }
s.author = { 'Devolutions' => 'lfauvel@devolutions.net' }
s.source = { :git => 'https://github.com/Devolutions/Slauth.git', :tag => s.version.to_s }
s.source = { :git => 'https://github.com/Devolutions/Slauth.git', :branch => 'devops/cloudsmith-cocoapods' }

s.swift_version = '5.0'
s.ios.deployment_target = '11.0'

s.source_files = 'wrappers/swift/classes/**/*', 'slauth.h'
s.vendored_libraries = 'target/universal/release/*.a', 'target/x86_64-apple-io/release/*.a', 'target/aarch64-apple-ios/release/*.a'
s.vendored_libraries = 'target/universal/release/*.a'
end
Binary file not shown.
Binary file added target/universal/release/libslauth_universal.a
Binary file not shown.
Binary file added target/x86_64-apple-ios/release/libslauth_x86.a
Binary file not shown.
8 changes: 5 additions & 3 deletions wrappers/swift/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
cargo install cargo-lipo

cargo lipo --release
mv target/universal/release/libslauth.a target/universal/release/libslauth_universal.a
mv target/x86_64-apple-ios/release/libslauth.a target/x86_64-apple-ios/release/libslauth_x86.a
mv target/aarch64-apple-ios/release/libslauth.a target/aarch64-apple-ios/release/libslauth_arm64.a
# mv target/universal/release/libslauth.a target/universal/release/libslauth_universal.a
# mv target/x86_64-apple-ios/release/libslauth.a target/x86_64-apple-ios/release/libslauth_x86.a
# mv target/aarch64-apple-ios/release/libslauth.a target/aarch64-apple-ios/release/libslauth_arm64.a

0 comments on commit 98ba6d0

Please sign in to comment.