chore: Bump version to 1.2.0 #34
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- "v*" | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
create_release: | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
release_id: ${{ steps.create_release.outputs.id }} | |
is_pre: ${{ steps.release_type.outputs.is_pre }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Conventional Commit Changelog | |
id: conventional_commits | |
run: | | |
curl -s -L -o./clog.tar.gz https://github.com/clog-tool/clog-cli/releases/download/v0.9.3/clog-v0.9.3-x86_64-unknown-linux-musl.tar.gz | |
tar -xf ./clog.tar.gz | |
chmod +x ./clog | |
# delete current tag locally | |
git tag -d "$GITHUB_REF_NAME" | |
if [[ "$GITHUB_REF_NAME" == *"-"* ]]; then | |
last_tag="$(git tag -l --sort version:refname | tail -n1)" | |
else | |
last_tag="$(git tag -l --sort version:refname | grep -v -- - | tail -n1)" | |
fi | |
printf 'Using %s as last tag\n' "$last_tag" | |
echo 'CHANGELOG<<EOF' >> $GITHUB_ENV | |
./clog --from="$last_tag" --setversion="$GITHUB_REF_NAME" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Determine release type | |
id: release_type | |
shell: bash | |
run: | | |
[[ "$GITHUB_REF_NAME" == *"-"* ]] && is_pre='true' || is_pre='false' | |
printf 'is_pre=%s\n' "$is_pre" >> $GITHUB_OUTPUT | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
draft: true | |
prerelease: ${{ steps.release_type.outputs.is_pre }} | |
body: ${{ env.CHANGELOG }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
extension: | |
name: Pack and upload MailExtension | |
needs: create_release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Zip | |
run: | | |
pushd ./extension | |
zip -r -FS ../external-editor-revived.xpi * | |
- name: Hash | |
run: | | |
echo "$(sha256sum external-editor-revived.xpi | cut -d ' ' -f 1)" > external-editor-revived.xpi.sha256sum | |
cat external-editor-revived.xpi.sha256sum | |
- name: Git Tag | |
id: git_tag | |
run: | | |
printf 'git_tag=%s\n' "$GITHUB_REF_NAME" >> $GITHUB_OUTPUT | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ./external-editor-revived.xpi | |
asset_name: external-editor-revived-${{ steps.git_tag.outputs.git_tag }}.xpi | |
asset_content_type: application/zip | |
- name: "Upload Hash" | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ./external-editor-revived.xpi.sha256sum | |
asset_name: external-editor-revived-${{ steps.git_tag.outputs.git_tag }}.xpi.sha256sum | |
asset_content_type: text/plain | |
messaging_host: | |
name: Build and upload native messaging host | |
runs-on: ${{ matrix.os }} | |
needs: create_release | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
target: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl] | |
include: | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install macOS Dependencies | |
if: contains(matrix.os, 'macos') | |
run: brew install coreutils | |
- name: Install Windows Dependencies | |
if: contains(matrix.os, 'windows') | |
run: choco install zip | |
- name: Install Rust Toolchain | |
id: rust_toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
- name: Add Linux Targets | |
if: contains(matrix.os, 'ubuntu') | |
run: | | |
rustup target add x86_64-unknown-linux-gnu | |
rustup target add x86_64-unknown-linux-musl | |
- name: Add macOS Targets | |
if: contains(matrix.os, 'macos') | |
run: | | |
rustup target add x86_64-apple-darwin | |
rustup target add aarch64-apple-darwin | |
- name: Determine Readable Target Name | |
id: readable_target | |
shell: bash | |
run: | | |
if [[ "${{ matrix.os }}" == "macos"* ]]; then | |
printf 'name=%s\n' "universal" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
case "${{ matrix.target }}" in | |
x86_64-unknown-linux-gnu) | |
printf 'name=%s\n' "gnu" >> $GITHUB_OUTPUT | |
;; | |
x86_64-unknown-linux-musl) | |
printf 'name=%s\n' "musl" >> $GITHUB_OUTPUT | |
;; | |
x86_64-pc-windows-msvc) | |
printf 'name=%s\n' "msvc" >> $GITHUB_OUTPUT | |
;; | |
esac | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-target-${{ steps.readable_target.outputs.name }}-lock-${{ hashFiles('Cargo.lock') }}-git-${{ github.sha }} | |
restore-keys: | | |
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-target-${{ steps.readable_target.outputs.name }}-lock-${{ hashFiles('Cargo.lock') }}- | |
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-target-${{ steps.readable_target.outputs.name }}- | |
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}- | |
build-${{ runner.os }}- | |
- name: rustfmt | |
shell: bash | |
run: | | |
cargo fmt -- --check | |
- name: Clippy | |
shell: bash | |
run: | | |
cargo clippy --locked --tests --target=${{ matrix.target }} -- -D warnings | |
- name: Test | |
shell: bash | |
run: | | |
cargo test --locked --release --target=${{ matrix.target }} | |
- name: Build (Linux, Windows) | |
if: "!contains(matrix.os, 'macos')" | |
shell: bash | |
run: | | |
cargo build --locked --release --target=${{ matrix.target }} | |
[[ "${{ matrix.os }}" == "windows"* ]] && EXT='.exe' || EXT='' | |
mv -f "target/${{ matrix.target }}/release/external-editor-revived${EXT}" "target/release/external-editor-revived${EXT}" | |
- name: Build (macOS, x86_64) | |
if: contains(matrix.os, 'macos') | |
shell: bash | |
run: | | |
cargo build --locked --release --target=x86_64-apple-darwin | |
- name: Build (macOS, aarch64) | |
if: contains(matrix.os, 'macos') | |
shell: bash | |
run: | | |
cargo build --locked --release --target=aarch64-apple-darwin | |
- name: macOS Universal Binary | |
if: contains(matrix.os, 'macos') | |
run: | | |
mkdir -p target/release/ | |
lipo -create -output target/release/external-editor-revived target/x86_64-apple-darwin/release/external-editor-revived target/aarch64-apple-darwin/release/external-editor-revived | |
file target/release/external-editor-revived | |
- name: Pack | |
id: pack_native_host | |
shell: bash | |
run: | | |
zip -j "./${{ matrix.os }}-${{ steps.readable_target.outputs.name }}-native-messaging-host-$GITHUB_REF_NAME.zip" target/release/external-editor-revived target/release/external-editor-revived.exe | |
echo "filename=${{ matrix.os }}-${{ steps.readable_target.outputs.name }}-native-messaging-host-$GITHUB_REF_NAME" >> $GITHUB_OUTPUT | |
- name: "Hash (Unix)" | |
if: "!contains(matrix.os, 'windows')" | |
run: | | |
echo "$(sha256sum ${{ steps.pack_native_host.outputs.filename }}.zip | cut -d ' ' -f 1)" > ${{ steps.pack_native_host.outputs.filename }}.zip.sha256sum | |
cat ${{ steps.pack_native_host.outputs.filename }}.zip.sha256sum | |
- name: "Hash (Windows)" | |
if: contains(matrix.os, 'windows') | |
run: | | |
$FileHash=(certutil -hashfile ${{ steps.pack_native_host.outputs.filename }}.zip SHA256 | findstr /v hash | findstr /v SHA).replace(" ", "") | |
echo "$FileHash" | |
echo "$FileHash" > ${{ steps.pack_native_host.outputs.filename }}.zip.sha256sum | |
- name: Upload | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ./${{ steps.pack_native_host.outputs.filename }}.zip | |
asset_name: ${{ steps.pack_native_host.outputs.filename }}.zip | |
asset_content_type: application/zip | |
- name: "Upload Hash" | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ./${{ steps.pack_native_host.outputs.filename }}.zip.sha256sum | |
asset_name: ${{ steps.pack_native_host.outputs.filename }}.zip.sha256sum | |
asset_content_type: text/plain | |
publish_release: | |
runs-on: ubuntu-latest | |
needs: [create_release, extension, messaging_host] | |
if: ${{ needs.create_release.outputs.is_pre == 'false' }} | |
steps: | |
- name: Publish Release | |
uses: eregon/publish-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ needs.create_release.outputs.release_id }} |