Skip to content

Commit

Permalink
Update Github Actions workflows
Browse files Browse the repository at this point in the history
* Update all Actions dependencies
* Use Rust triple instead of LLVM triple
* Remove unnecessary explicit installation of clippy

Signed-off-by: Andrew Gunnerson <[email protected]>
  • Loading branch information
chenxiaolong committed Apr 14, 2024
1 parent 8391996 commit 92a8828
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 41 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Get Rust LLVM target triple
- name: Get Rust target triple
id: get_target
shell: bash
run: |
echo -n 'name=' >> "${GITHUB_OUTPUT}"
RUSTC_BOOTSTRAP=1 rustc -Z unstable-options --print target-spec-json \
| jq -r '."llvm-target"' \
>> "${GITHUB_OUTPUT}"
- name: Install clippy
run: rustup component add clippy
rustc -vV | sed -n 's|host: ||p' >> "${GITHUB_OUTPUT}"
- name: Run tests in debug mode
env:
Expand All @@ -44,7 +42,7 @@ jobs:
run: cargo build --verbose

- name: Archive artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ddns-updater-${{ steps.get_target.outputs.name }}
path: |
Expand Down
53 changes: 22 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
tags:
- 'v*'
jobs:
create_release:
name: Create GitHub release
get_version:
name: Get version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
Expand All @@ -23,40 +23,32 @@ jobs:
fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: Version ${{ steps.get_version.outputs.version }}

build_and_upload:
name: Build and upload assets
needs: create_release
needs: get_version
runs-on: ${{ matrix.os }}
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -C strip=symbols
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Get Rust LLVM target triple
- name: Get Rust target triple
id: get_target
shell: bash
run: |
echo -n 'name=' >> "${GITHUB_OUTPUT}"
RUSTC_BOOTSTRAP=1 rustc -Z unstable-options --print target-spec-json \
| jq -r '."llvm-target"' \
>> "${GITHUB_OUTPUT}"
- name: Install clippy
run: rustup component add clippy
rustc -vV | sed -n 's|host: ||p' >> "${GITHUB_OUTPUT}"
- name: Run tests in release mode
env:
Expand All @@ -66,16 +58,13 @@ jobs:
cargo test --workspace --release
- name: Build in release mode
run: cargo build --release --verbose

- name: Strip release binary (non-Windows)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: strip target/release/ddns-updater
run: cargo build --release

- name: Build archive
id: build_archive
shell: bash
run: |
base_name=ddns-updater-${{ needs.create_release.outputs.version }}-${{ steps.get_target.outputs.name }}
base_name=ddns-updater-${{ needs.get_version.outputs.version }}-${{ steps.get_target.outputs.name }}
mkdir "${base_name}"
cp {README.md,LICENSE} "${base_name}/"
Expand All @@ -91,13 +80,15 @@ jobs:
openssl sha512 -r "${asset}" | sed 's/\*/ /' > "${asset}.sha512"
echo "ASSET=${asset}" >> "${GITHUB_ENV}"
echo "ASSET_SHA512=${asset}.sha512" >> "${GITHUB_ENV}"
echo "name=${asset}" >> "${GITHUB_OUTPUT}"
echo "name_sha512=${asset}.sha512" >> "${GITHUB_OUTPUT}"
- name: Upload release assets
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.create_release.outputs.version }}
tag_name: v${{ needs.get_version.outputs.version }}
name: Version ${{ needs.get_version.outputs.version }}
draft: true
files: |
${{ env.ASSET }}
${{ env.ASSET_SHA512 }}
${{ steps.build_archive.outputs.name }}
${{ steps.build_archive.outputs.name_sha512 }}

0 comments on commit 92a8828

Please sign in to comment.