From 51c9cec2bdedfd19284b97372fdc2bf7f760aa79 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 18 Nov 2020 07:51:42 +0900 Subject: [PATCH] ci: switch from local scripts to taiki-e/github-actions actions --- .github/workflows/ci.yml | 28 ++++++++++-------- .github/workflows/release.yml | 10 ++----- ci/create-release.sh | 47 ------------------------------- ci/install-component.sh | 23 --------------- ci/install-rust.sh | 10 ------- scripts/check-minimal-versions.sh | 7 +++-- 6 files changed, 24 insertions(+), 101 deletions(-) delete mode 100755 ci/create-release.sh delete mode 100755 ci/install-component.sh delete mode 100755 ci/install-rust.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66ae2d35..c385d139 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,8 +39,9 @@ jobs: runs-on: ${{ matrix.os || 'ubuntu-latest' }} steps: - uses: actions/checkout@v2 - - name: Install Rust - run: ci/install-rust.sh ${{ matrix.rust }} + - uses: taiki-e/github-actions/install-rust@main + with: + toolchain: ${{ matrix.rust }} - if: startsWith(matrix.rust, 'nightly') run: cargo install cargo-hack - run: rustup target add thumbv7m-none-eabi @@ -54,8 +55,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust and Rustfmt - run: ci/install-component.sh rustfmt + - uses: taiki-e/github-actions/install-rust@main + with: + component: rustfmt - name: Fetch latest release version of cargo-expand run: | mkdir -p .github/caching @@ -76,24 +78,27 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust and Miri - run: ci/install-component.sh miri + - uses: taiki-e/github-actions/install-rust@main + with: + component: miri - run: cargo miri test clippy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust and Clippy - run: ci/install-component.sh clippy + - uses: taiki-e/github-actions/install-rust@main + with: + component: clippy - run: cargo clippy --all --all-features --all-targets rustfmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust and Rustfmt - run: ci/install-component.sh rustfmt + - uses: taiki-e/github-actions/install-rust@main + with: + component: rustfmt - run: cargo fmt --all -- --check rustdoc: @@ -102,8 +107,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust - run: ci/install-rust.sh + - run: taiki-e/github-actions/install-rust@main - run: cargo doc --no-deps --all --all-features shellcheck: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0c9458f..b6b85a3a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,13 +1,9 @@ -name: release +name: Release on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - -defaults: - run: - shell: bash + - 'v*' jobs: create-release: @@ -15,6 +11,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: ci/create-release.sh + - run: taiki-e/github-actions/create-release@main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/ci/create-release.sh b/ci/create-release.sh deleted file mode 100755 index 47e00750..00000000 --- a/ci/create-release.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# Create a new GitHub release. -# -# Note: -# - The generated note format is: -# "See the [release notes]($LINK_TO_CHANGELOG) for a complete list of changes." -# - The generated link format is: -# "https://github.com/$GITHUB_REPOSITORY/blob/HEAD/CHANGELOG.md#${TAG/v/}---${RELEASE_DATE}" -# - This script assumes that the format (file name and title of section) of -# release notes is based on Keep a Changelog (https://keepachangelog.com/en/1.0.0). -# - The valid tag format is "vMAJOR.MINOR.PATCH(-PRERELEASE)(+BUILD_METADATA)" -# See also Semantic Versioning (https://semver.org) -# - The release date is based on the time this script was run, the time zone is -# the UTC. -# - The generated link to the release notes will be broken when the version -# yanked if the project adheres to the Keep a Changelog's yanking style. -# Consider adding a note like the following instead of using the "[YANKED]" tag: -# "**Note: This release has been yanked.** See $LINK_TO_YANKED_REASON for details." - -set -euo pipefail -IFS=$'\n\t' - -ref="${GITHUB_REF:?}" -tag="${ref#*/tags/}" - -if [[ ! "${tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z_0-9\.-]+)?(\+[a-zA-Z_0-9\.-]+)?$ ]]; then - echo "error: invalid tag format: ${tag}" - exit 1 -elif [[ "${tag}" =~ ^v[0-9\.]+-[a-zA-Z_0-9\.-]+(\+[a-zA-Z_0-9\.-]+)?$ ]]; then - prerelease="--prerelease" -fi -version="${tag/v/}" -date=$(date --utc '+%Y-%m-%d') -title="${version}" -changelog="https://github.com/${GITHUB_REPOSITORY:?}/blob/HEAD/CHANGELOG.md#${version//./}---${date}" -notes="See the [release notes](${changelog}) for a complete list of changes." - -if [[ -z "${GITHUB_TOKEN:-}" ]]; then - echo "GITHUB_TOKEN not set, skipping deploy" - exit 1 -else - if gh release view "${tag}" &>/dev/null; then - gh release delete "${tag}" -y - fi - gh release create "${tag}" ${prerelease:-} --title "${title}" --notes "${notes}" -fi diff --git a/ci/install-component.sh b/ci/install-component.sh deleted file mode 100755 index 5d905419..00000000 --- a/ci/install-component.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Install nightly Rust with a given component. -# -# If the component is unavailable on the latest nightly, -# use the latest toolchain with the component available. -# -# When using stable Rust, this script is basically unnecessary as almost components available. -# -# Refs: https://github.com/rust-lang/rustup-components-history#the-web-part - -set -euo pipefail -IFS=$'\n\t' - -package="${1:?}" -target="${2:-x86_64-unknown-linux-gnu}" - -toolchain=nightly-$(curl -sSf https://rust-lang.github.io/rustup-components-history/"${target}"/"${package}") - -# shellcheck disable=1090 -"$(cd "$(dirname "${0}")" && pwd)"/install-rust.sh "${toolchain}" - -rustup component add "${package}" diff --git a/ci/install-rust.sh b/ci/install-rust.sh deleted file mode 100755 index 3fcf5579..00000000 --- a/ci/install-rust.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -euo pipefail -IFS=$'\n\t' - -toolchain="${1:-nightly}" - -# --no-self-update is necessary because the windows environment cannot self-update rustup.exe. -rustup toolchain install "${toolchain}" --no-self-update --profile minimal -rustup default "${toolchain}" diff --git a/scripts/check-minimal-versions.sh b/scripts/check-minimal-versions.sh index 5e767f77..56fadee2 100755 --- a/scripts/check-minimal-versions.sh +++ b/scripts/check-minimal-versions.sh @@ -35,8 +35,11 @@ fi # Parse subcommand. subcmd="${1:-check}" -if [[ ! "${subcmd}" =~ check|test ]]; then - echo "error: invalid argument \`${1}\`" +if [[ ! "${subcmd}" =~ ^(check|test)$ ]]; then + echo "error: invalid argument: ${1}" + exit 1 +elif [[ -n "${2:-}" ]]; then + echo "error: invalid argument: ${2}" exit 1 fi