signal-cli/.github/workflows/release.yml
2022-11-03 15:33:28 +01:00

291 lines
9.6 KiB
YAML

name: release
on:
push:
tags:
- v*
env:
IMAGE_NAME: signal-cli
IMAGE_REGISTRY: ghcr.io/asamk
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
jobs:
ci_wf:
uses: AsamK/signal-cli/.github/workflows/ci.yml@master
# ${{ github.repository }} not accepted here
lib_to_jar:
needs: ci_wf
runs-on: ubuntu-latest
outputs:
signal_cli_version: ${{ steps.cli_ver.outputs.version }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Download signal-cli build from CI workflow
uses: actions/download-artifact@v3
- name: Get signal-cli version
id: cli_ver
run: |
ver="${GITHUB_REF_NAME#v}"
echo "version=${ver}" >> $GITHUB_OUTPUT
- name: Extract archive
run: |
tree .
ARCHIVE_DIR=$(ls signal-cli-archive-*/ -d | tail -n1)
tar -xzf ./"${ARCHIVE_DIR}"/*.tar.gz
mv ./"${ARCHIVE_DIR}"/*.tar.gz signal-cli-${{ steps.cli_ver.outputs.version }}-Linux.tar.gz
rm -rf signal-cli-archive-*/
- name: Get signal-client jar version
id: lib_ver
run: |
JAR_PREFIX=libsignal-client-
jar_file=$(find ./signal-cli-*/lib/ -name "$JAR_PREFIX*.jar")
jar_version=$(echo "$jar_file" | xargs basename | sed "s/$JAR_PREFIX//; s/.jar//")
echo "$jar_version"
echo "signal_client_version=${jar_version}" >> $GITHUB_OUTPUT
- name: Download signal-client builds
env:
RELEASES_URL: https://github.com/signalapp/libsignal/releases/download/
FILE_NAMES: signal_jni.dll libsignal_jni.dylib
SIGNAL_CLIENT_VER: ${{ steps.lib_ver.outputs.signal_client_version }}
run: |
for file_name in $FILE_NAMES; do
curl -sOL "${RELEASES_URL}/v${SIGNAL_CLIENT_VER}/${file_name}" # note: added v
done
tree .
- name: Compress native app
env:
SIGNAL_CLI_VER: ${{ steps.cli_ver.outputs.version }}
run: |
chmod +x signal-cli-native/signal-cli
tar -czf signal-cli-${SIGNAL_CLI_VER}-Linux-native.tar.gz -C signal-cli-native signal-cli
rm -rf signal-cli-native/
- name: Replace Windows lib
env:
SIGNAL_CLI_VER: ${{ steps.cli_ver.outputs.version }}
SIGNAL_CLIENT_VER: ${{ steps.lib_ver.outputs.signal_client_version }}
run: |
mv signal_jni.dll libsignal_jni.so
zip -u ./signal-cli-*/lib/libsignal-client-${SIGNAL_CLIENT_VER}.jar ./libsignal_jni.so
tar -czf signal-cli-${SIGNAL_CLI_VER}-Windows.tar.gz signal-cli-*/
- name: Replace macOS lib
env:
SIGNAL_CLI_VER: ${{ steps.cli_ver.outputs.version }}
SIGNAL_CLIENT_VER: ${{ steps.lib_ver.outputs.signal_client_version }}
run: |
jar_file=./signal-cli-*/lib/libsignal-client-${SIGNAL_CLIENT_VER}.jar
zip -d $jar_file libsignal_jni.so
zip $jar_file libsignal_jni.dylib
tar -czf signal-cli-${SIGNAL_CLI_VER}-macOS.tar.gz signal-cli-*/
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.cli_ver.outputs.version }} # note: added `v`
release_name: v${{ steps.cli_ver.outputs.version }} # note: added `v`
draft: true
- name: Upload Linux archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: signal-cli-${{ steps.cli_ver.outputs.version }}-Linux.tar.gz
asset_name: signal-cli-${{ steps.cli_ver.outputs.version }}-Linux.tar.gz
asset_content_type: application/x-compressed-tar # .tar.gz
- name: Upload Linux native archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: signal-cli-${{ steps.cli_ver.outputs.version }}-Linux-native.tar.gz
asset_name: signal-cli-${{ steps.cli_ver.outputs.version }}-Linux-native.tar.gz
asset_content_type: application/x-compressed-tar # .tar.gz
- name: Upload windows archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: signal-cli-${{ steps.cli_ver.outputs.version }}-Windows.tar.gz
asset_name: signal-cli-${{ steps.cli_ver.outputs.version }}-Windows.tar.gz
asset_content_type: application/x-compressed-tar # .tar.gz
- name: Upload macos archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: signal-cli-${{ steps.cli_ver.outputs.version }}-macOS.tar.gz
asset_name: signal-cli-${{ steps.cli_ver.outputs.version }}-macOS.tar.gz
asset_content_type: application/x-compressed-tar # .tar.gz
run_repackaged:
needs:
- lib_to_jar
strategy:
matrix:
runner:
- windows-latest
- macos-latest
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: bash # Explicit for windows
env:
JAVA_VERSION: 19
steps:
- name: Download the release file
env:
SIGNAL_CLI_VER: ${{ needs.lib_to_jar.outputs.signal_cli_version }}
RELEASE_ID: ${{ needs.lib_to_jar.outputs.release_id }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
file_name=signal-cli-${SIGNAL_CLI_VER}-${RUNNER_OS}.tar.gz
echo "$file_name"
assets_json=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets")
asset_dl_url=$(echo "$assets_json" | jq -r ".[] | select (.name == \"$file_name\") | .url")
echo "$asset_dl_url"
curl -sLOJ \
-H 'Accept: application/octet-stream' \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"$asset_dl_url"
tar -xzf "$file_name"
- name: Set up JDK for running signal-cli executable
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: ${{ env.JAVA_VERSION }}
java-package: 'jre'
- name: Run signal-cli
run: |
cd signal-cli-*/bin
if [[ "$RUNNER_OS" == 'Windows' ]]; then
EXECUTABLE_SUFFIX=".bat"
fi
./signal-cli${EXECUTABLE_SUFFIX} listAccounts
build-container:
needs: ci_wf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download signal-cli build from CI workflow
uses: actions/download-artifact@v3
- name: Get signal-cli version
id: cli_ver
run: |
ver="${GITHUB_REF_NAME#v}"
echo "version=${ver}" >> $GITHUB_OUTPUT
- name: Move archive file
run: |
ARCHIVE_DIR=$(ls signal-cli-archive-*/ -d | tail -n1)
tar xf ./"${ARCHIVE_DIR}"/*.tar.gz
rm -r signal-cli-archive-* signal-cli-native
mkdir -p build/install/
mv ./signal-cli-*/ build/install/signal-cli
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: latest ${{ github.sha }} ${{ steps.cli_ver.outputs.version }}
containerfiles:
./Containerfile
oci: true
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
id: push
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Echo outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"
build-container-native:
needs: ci_wf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download signal-cli build from CI workflow
uses: actions/download-artifact@v3
- name: Get signal-cli version
id: cli_ver
run: |
ver="${GITHUB_REF_NAME#v}"
echo "version=${ver}" >> $GITHUB_OUTPUT
- name: Move archive file
run: |
mkdir -p build/native/nativeCompile/
chmod +x ./signal-cli-native/signal-cli
mv ./signal-cli-native/signal-cli build/native/nativeCompile/
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: latest-native ${{ github.sha }}-native ${{ steps.cli_ver.outputs.version }}-native
containerfiles:
./native.Containerfile
oci: true
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
id: push
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Echo outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"