zed-discord-presence/.github/workflows/release.yml

133 lines
3.6 KiB
YAML
Raw Normal View History

2024-07-19 16:26:21 +02:00
name: Release
on:
workflow_dispatch:
2024-07-19 17:32:21 +02:00
inputs:
version:
description: "lsp version"
required: true
2024-07-19 16:26:21 +02:00
jobs:
check:
name: check
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: install rust
2024-07-19 16:28:47 +02:00
uses: ./.github/actions/install-rust
2024-07-19 16:26:21 +02:00
- name: check
2024-07-19 16:28:47 +02:00
uses: ./.github/actions/check
2024-07-19 16:26:21 +02:00
compile:
name: compile ${{ matrix.target }}
2024-07-19 16:44:10 +02:00
runs-on: ${{ matrix.runner }}
2024-07-19 16:26:21 +02:00
needs: check
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
archive: tar.gz
bootstrap: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
2024-07-19 16:26:21 +02:00
- target: x86_64-apple-darwin
runner: macos-latest
archive: tar.gz
bootstrap: brew install openssl pkg-config
2024-07-19 16:26:21 +02:00
- target: aarch64-apple-darwin
runner: macos-latest
archive: tar.gz
bootstrap: brew install openssl pkg-config
2024-07-19 16:26:21 +02:00
- target: x86_64-pc-windows-msvc
runner: windows-latest
archive: zip
steps:
- name: checkout
uses: actions/checkout@v4
2024-07-19 16:36:28 +02:00
- name: install rust
uses: ./.github/actions/install-rust
with:
targets: "${{ matrix.target }}"
2024-07-21 14:49:42 +02:00
- name: bootstrap
2024-07-21 14:51:27 +02:00
if: ${{ matrix.bootstrap != '' }}
2024-07-21 14:49:42 +02:00
run: ${{ matrix.bootstrap }}
2024-07-19 16:26:21 +02:00
- name: build binary
run: cargo build -p discord-presence-lsp --verbose --locked --release --target ${{ matrix.target }}
- name: prepare for upload
2024-07-19 17:04:35 +02:00
shell: bash
2024-07-19 16:26:21 +02:00
id: vars
run: |
BIN_SUFFIX=""
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
BIN_SUFFIX=".exe"
fi
BIN_OUTPUT="target/${{ matrix.target }}/release/discord-presence-lsp${BIN_SUFFIX}"
ARCHIVE_NAME="discord-presence-lsp-${{ matrix.target }}"
mkdir tmp/
mkdir "tmp/${ARCHIVE_NAME}"
mv "${BIN_OUTPUT}" "tmp/${ARCHIVE_NAME}"
cp LICENSE "tmp/${ARCHIVE_NAME}"
cp lsp/README.md "tmp/${ARCHIVE_NAME}"
if [[ "${{ matrix.archive }}" == "tar.gz" ]]; then
ARCHIVE_PATH="tmp/${ARCHIVE_NAME}.tar.gz"
2024-07-19 17:32:21 +02:00
tar -czvf "${ARCHIVE_PATH}" -C "tmp" "${ARCHIVE_NAME}"
2024-07-19 16:26:21 +02:00
else
ARCHIVE_PATH="tmp/${ARCHIVE_NAME}.zip"
2024-07-19 17:32:21 +02:00
cd tmp
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
2024-07-19 17:32:21 +02:00
7z a "../${ARCHIVE_PATH}" "${ARCHIVE_NAME}"
else
2024-07-19 17:32:21 +02:00
zip -r "../${ARCHIVE_PATH}" "/${ARCHIVE_NAME}"
fi
2024-07-19 17:32:21 +02:00
cd ..
2024-07-19 16:26:21 +02:00
fi
2024-07-19 16:54:50 +02:00
echo "archive_name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
2024-07-19 16:26:21 +02:00
echo "archive_path=${ARCHIVE_PATH}" >> $GITHUB_OUTPUT
- name: upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.vars.outputs.archive_name }}
path: |
${{ steps.vars.outputs.archive_path }}
2024-07-19 17:32:21 +02:00
release:
name: release
runs-on: ubuntu-latest
2024-07-19 17:33:52 +02:00
needs: compile
2024-07-19 17:38:05 +02:00
permissions:
contents: write
2024-07-19 17:32:21 +02:00
steps:
- name: checkout
uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create the release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ inputs.version }}
name: v${{ inputs.version }}
draft: true
files: |
artifacts/**/*