lapce/.github/workflows/release.yml

279 lines
9.9 KiB
YAML
Raw Normal View History

2021-10-06 11:42:43 +00:00
name: Release
on:
2022-08-01 11:39:44 +00:00
schedule:
- cron: 0 0 * * *
2022-06-28 19:44:02 +00:00
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for release'
required: false
default: nightly
2021-10-06 11:42:43 +00:00
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_TERM_COLOR: always
jobs:
2022-08-20 20:18:24 +00:00
tagname:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag.outputs.tag }}
steps:
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: echo 'TAG_NAME=nightly' >> $GITHUB_ENV
- if: github.event_name == 'push'
run: |
TAG_NAME=${{ github.ref }}
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
- id: vars
shell: bash
2022-08-20 20:39:44 +00:00
run: echo "::set-output name=sha_short::${GITHUB_SHA::7}"
2022-08-20 20:18:24 +00:00
- if: env.TAG_NAME == 'nightly'
run: echo 'TAG_NAME=nightly-${{ steps.vars.outputs.sha_short }}' >> $GITHUB_ENV
- id: tag
run: echo "::set-output name=tag::$TAG_NAME"
2021-10-06 15:49:54 +00:00
windows:
runs-on: windows-latest
2022-08-20 20:18:24 +00:00
needs: tagname
env:
RELEASE_TAG_NAME: ${{ needs.tagname.outputs.tag_name }}
2021-10-06 15:49:54 +00:00
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
2021-10-26 15:52:05 +00:00
- name: Update rust
run: rustup update
2021-10-06 15:49:54 +00:00
- name: Build
run: cargo build --profile release-lto
2021-10-06 15:49:54 +00:00
- name: Install WiX
run: nuget install WiX
- name: Crate msi installer
run: |
2021-10-06 16:19:26 +00:00
./WiX.*/tools/candle.exe -arch "x64" -ext WixUIExtension -ext WixUtilExtension \
2021-10-06 15:49:54 +00:00
-out "./lapce.wixobj" "extra/windows/wix/lapce.wxs"
2021-10-06 16:19:26 +00:00
./WiX.*/tools/light.exe -ext WixUIExtension -ext WixUtilExtension \
2021-10-06 19:20:07 +00:00
-out "./Lapce-windows.msi" -sice:ICE61 -sice:ICE91 \
2021-10-06 15:49:54 +00:00
"./lapce.wixobj"
2022-06-16 14:24:07 +00:00
- name: Create portable
2022-03-04 13:50:24 +00:00
shell: pwsh
2022-03-03 09:38:43 +00:00
run: |
2022-05-11 20:35:38 +00:00
Compress-Archive ./target/release-lto/lapce.exe ./Lapce-windows-portable.zip
2022-08-06 11:36:18 +00:00
- name: Create lapce-proxy archive
shell: pwsh
run: |
$file = [System.IO.File]::Open((Join-Path $PWD '.\target\release-lto\lapce-proxy.exe'), [System.IO.FileMode]::Open)
$archive = [System.IO.File]::Create((Join-Path $PWD '.\lapce-proxy-windows-x86_64.gz'))
$compressor = [System.IO.Compression.GZipStream]::new($archive, [System.IO.Compression.CompressionMode]::Compress)
$file.CopyTo($compressor)
Start-Sleep -Seconds 10
$compressor.close()
2022-07-01 20:48:19 +00:00
- uses: actions/upload-artifact@v3
2021-10-06 15:49:54 +00:00
with:
2022-07-01 20:48:19 +00:00
name: lapce-windows
path: |
2022-08-06 11:36:18 +00:00
./lapce-proxy-windows-*.gz
2022-07-01 20:48:19 +00:00
./Lapce-windows-portable.zip
./Lapce-windows.msi
retention-days: 1
2021-10-06 15:49:54 +00:00
2021-12-30 17:10:46 +00:00
linux:
runs-on: ubuntu-18.04
2022-08-20 20:18:24 +00:00
needs: tagname
env:
RELEASE_TAG_NAME: ${{ needs.tagname.outputs.tag_name }}
2021-12-30 17:10:46 +00:00
2021-12-30 17:14:01 +00:00
steps:
2021-12-30 17:10:46 +00:00
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
2022-05-19 13:02:48 +00:00
sudo apt-get install cmake pkg-config libfontconfig-dev libgtk-3-dev
2021-12-30 17:10:46 +00:00
- name: Update rust
run: rustup update
- name: Build
run: cargo build --profile release-lto --bin lapce
2022-06-16 14:24:07 +00:00
- name: Gzip
2021-12-30 17:10:46 +00:00
run: |
2021-12-30 17:24:11 +00:00
mkdir Lapce
2022-05-11 20:35:38 +00:00
cp ./target/release-lto/lapce Lapce/
2021-12-30 17:24:11 +00:00
tar -zcvf ./Lapce-linux.tar.gz Lapce
2022-07-01 20:48:19 +00:00
- uses: actions/upload-artifact@v3
2021-12-30 17:27:28 +00:00
with:
2022-07-01 20:48:19 +00:00
name: lapce-linux
path: |
./Lapce-linux.tar.gz
retention-days: 1
linux-musl:
name: Build lapce-proxy for ${{ matrix.platform }}
runs-on: ubuntu-latest
2022-08-20 20:18:24 +00:00
needs: tagname
env:
2022-08-20 20:18:24 +00:00
RELEASE_TAG_NAME: ${{ needs.tagname.outputs.tag_name }}
CROSS_SYSROOT: /mnt/alpine-${{ matrix.platform }}
PACKAGES: >
zlib-static freetype-static fontconfig-static
libgit2-static libssh2-static openssl-libs-static
libssl3 gtk+3.0-dev http-parser-dev rustup
build-base openssl-dev git lld clang
strategy:
fail-fast: false
matrix:
include:
- triple: x86_64-unknown-linux-musl
platform: x86_64
- triple: aarch64-unknown-linux-musl
platform: aarch64
steps:
- uses: actions/checkout@v2
- name: Set up Alpine Linux for ${{ matrix.platform }} (target arch)
id: alpine-target
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.platform }}
branch: edge
packages: ${{ env.PACKAGES }}
shell-name: alpine-target.sh
- name: Set up Alpine Linux for x86_64 (build arch)
uses: jirutka/setup-alpine@v1
with:
arch: x86_64
packages: ${{ env.PACKAGES }}
volumes: ${{ steps.alpine-target.outputs.root-path }}:${{ env.CROSS_SYSROOT }}
shell-name: alpine.sh
- name: Install Rust stable toolchain via rustup
run: rustup-init --target ${{ matrix.triple }} --default-toolchain stable --profile minimal -y
shell: alpine.sh {0}
- name: Build ${{ matrix.triple }}
shell: alpine.sh {0}
env:
LIBZ_SYS_STATIC: 1
LIBSSH2_STATIC: 1
LIBGIT2_STATIC: 1
OPENSSL_STATIC: 1
OPENSSL_DIR: ${{ env.CROSS_SYSROOT }}/usr # static/dynamic lib workaround <3
OPENSSL_NO_VENDOR: 1 # don't even try to build without it on musl
PKG_CONFIG_ALL_STATIC: 1
PKG_CONFIG_LIBDIR: ${{ env.CROSS_SYSROOT }}/usr/lib/pkgconfig
RUSTFLAGS: -C target-feature=+crt-static -C linker=/usr/bin/ld.lld # link runtime static, use universal linker
CARGO_BUILD_TARGET: ${{ matrix.triple }}
CARGO_PROFILE_RELEASE_LTO: 'true'
CARGO_PROFILE_RELEASE_STRIP: symbols # remove unneeded debug stuff
CARGO_PROFILE_RELEASE_OPT_LEVEL: 's' # optimise for size
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1' # optimise each crate
SYSROOT: /dummy # workaround for https://github.com/rust-lang/pkg-config-rs/issues/102
CC: clang
run: |
# Workaround for https://github.com/rust-lang/pkg-config-rs/issues/102
echo -e '#!/bin/sh\nPKG_CONFIG_SYSROOT_DIR=${{ env.CROSS_SYSROOT }} exec pkgconf "$@"' \
| install -m755 /dev/stdin pkg-config
export PKG_CONFIG="$(pwd)/pkg-config"
cargo build \
--locked \
--verbose \
--release \
--bin lapce-proxy \
--manifest-path lapce-proxy/Cargo.toml
- name: Gzip
run: |
gzip -c ./target/${{ matrix.triple }}/release/lapce-proxy > ./lapce-proxy-linux-${{ matrix.platform }}.gz
- uses: actions/upload-artifact@v3
with:
name: lapce-proxy-linux-${{ matrix.platform }}
path: |
./lapce-proxy-linux-*.gz
2022-07-01 20:48:19 +00:00
retention-days: 1
2021-12-30 17:10:46 +00:00
2021-10-06 11:42:43 +00:00
macos:
runs-on: macos-11
2022-08-20 20:18:24 +00:00
needs: tagname
env:
RELEASE_TAG_NAME: ${{ needs.tagname.outputs.tag_name }}
2021-10-06 11:42:43 +00:00
2021-10-11 10:05:08 +00:00
NOTARIZE_USERNAME: ${{ secrets.NOTARIZE_USERNAME }}
NOTARIZE_PASSWORD: ${{ secrets.NOTARIZE_PASSWORD }}
2021-10-06 11:42:43 +00:00
steps:
- uses: actions/checkout@v2
- name: Install ARM target
run: rustup update && rustup target add aarch64-apple-darwin
2021-10-08 19:38:33 +00:00
- name: Import Certificate
2021-10-08 19:46:17 +00:00
uses: apple-actions/import-codesign-certs@v1
2022-06-16 14:24:07 +00:00
with:
2021-10-08 19:46:17 +00:00
p12-file-base64: ${{ secrets.MACOS_CERTIFICATE }}
p12-password: ${{ secrets.MACOS_CERTIFICATE_PWD }}
2021-10-08 19:38:33 +00:00
- name: Make DMG
run: make dmg-universal
- name: Rename
run: |
2022-05-11 20:35:38 +00:00
cp ./target/release-lto/macos/Lapce.dmg ./target/release-lto/macos/Lapce-macos.dmg
2022-08-06 13:09:44 +00:00
- name: Gzip lapce-proxy
run: |
2022-08-07 12:22:37 +00:00
gzip -c ./target/x86_64-apple-darwin/release-lto/lapce-proxy > ./target/release-lto/macos/lapce-proxy-darwin-x86_64.gz
gzip -c ./target/aarch64-apple-darwin/release-lto/lapce-proxy > ./target/release-lto/macos/lapce-proxy-darwin-aarch64.gz
2021-10-09 20:32:46 +00:00
- name: "Notarize Release Build"
2021-10-11 10:05:08 +00:00
run: |
2022-05-11 20:35:38 +00:00
npx notarize-cli --file ./target/release-lto/macos/Lapce-macos.dmg --bundle-id io.lapce --asc-provider CYSGAZFR8D
2021-10-09 20:32:46 +00:00
- name: "Staple Release Build"
uses: devbotsxyz/xcode-staple@v1
with:
2022-05-11 20:35:38 +00:00
product-path: "./target/release-lto/macos/Lapce-macos.dmg"
2022-07-01 20:48:19 +00:00
- uses: actions/upload-artifact@v3
with:
name: lapce-macos
path: |
2022-08-07 12:22:37 +00:00
./target/release-lto/macos/lapce-proxy-darwin-*.gz
2022-07-01 20:48:19 +00:00
./target/release-lto/macos/Lapce-macos.dmg
retention-days: 1
2022-06-28 20:56:23 +00:00
2022-07-01 20:48:19 +00:00
publish:
needs: [linux, linux-musl, windows, macos]
2022-07-01 20:48:19 +00:00
runs-on: ubuntu-20.04
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
# Must perform checkout first, since it deletes the target directory
# before running, and would therefore delete the downloaded artifacts
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
2022-06-28 20:56:23 +00:00
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: echo 'TAG_NAME=nightly' >> $GITHUB_ENV
- if: github.event_name == 'push'
run: |
TAG_NAME=${{ github.ref }}
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
2022-07-01 20:48:19 +00:00
- if: env.TAG_NAME == 'nightly'
run: |
(echo 'SUBJECT=Lapce development build';
echo 'PRERELEASE=--prerelease') >> $GITHUB_ENV
gh release delete nightly --yes || true
git push origin :nightly || true
- if: env.TAG_NAME != 'nightly'
run: |
(echo 'SUBJECT=Lapce release build';
echo 'PRERELEASE=') >> $GITHUB_ENV
- name: Publish release
env:
DEBUG: api
run: |
2022-08-20 20:19:57 +00:00
gh release create $TAG_NAME $PRERELEASE --title "$TAG_NAME" --target $GITHUB_SHA lapce-macos/* lapce-linux/* lapce-proxy-linux-*/* lapce-windows/*