From 237aeecdcab7d273a8d9c7136e2217fc5052ee92 Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Fri, 13 May 2022 20:08:53 +0300 Subject: [PATCH] release action --- .github/workflows/ci.yaml | 7 +++- .github/workflows/release.yml | 77 ++++++++++++++++++++++++++++++++++ .github/workflows/rust-ci.yaml | 17 ++++---- CHANGELOG-rust.md | 1 + 4 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1136054b..4964405f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,8 @@ name: CI +env: + SVDTOOLS: svd + on: push: branches: [ staging, trying, master ] @@ -11,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Python uses: actions/setup-python@v2 with: @@ -40,7 +43,7 @@ jobs: - rp2040 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Rust uses: actions-rs/toolchain@v1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..a15c4a40 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,77 @@ +name: release +on: + push: + branches: + - master + tags: + - v*.*.* + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + include: + - { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, suffix: .gz } + - { target: x86_64-apple-darwin, os: macos-latest, suffix: .gz } + - { target: aarch64-apple-darwin, os: macos-latest, suffix: .gz } + - { target: x86_64-pc-windows-msvc, os: windows-latest, suffix: .zip } + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + target: ${{ matrix.target }} + override: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + with: + key: ${{ matrix.target }} + - uses: actions-rs/cargo@v1 + with: + command: build + args: --target ${{ matrix.target }} --release + + - name: (Not Windows) Move executables and compress + if: ${{ matrix.os != 'windows-latest' }} + run: gzip -c target/${{ matrix.target }}/release/svdtools > svdtools-${{ matrix.target }}${{ matrix.suffix }} + + - name: (Windows) Move executables and compress + if: ${{ matrix.os == 'windows-latest' }} + run: Compress-Archive -Path target\${{ matrix.target }}\release\svdtools.exe -DestinationPath svdtools-${{ matrix.target }}${{ matrix.suffix }} + + - uses: actions/upload-artifact@v3 + with: + name: svdtools-${{ matrix.target }} + path: svdtools-${{ matrix.target }}${{ matrix.suffix }} + + release: + name: release + runs-on: ubuntu-latest + needs: [build] + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + path: artifacts + - run: ls -R ./artifacts + + - name: Set current date as environment variable + run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + + - id: changelog-reader + uses: mindsers/changelog-reader-action@v2.0.0 + with: + path: ./CHANGELOG-rust.md + version: ${{ (github.ref_type == 'tag' && github.ref_name) || 'Unreleased' }} + + - uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.changelog-reader.outputs.version }} + name: ${{ (github.ref_type == 'tag' && steps.changelog-reader.outputs.version) || format('Prereleased {0}', env.CURRENT_DATE) }} + body: ${{ steps.changelog-reader.outputs.changes }} + prerelease: ${{ steps.changelog-reader.outputs.status == 'unreleased' }} + files: | + artifacts/**/* diff --git a/.github/workflows/rust-ci.yaml b/.github/workflows/rust-ci.yaml index 88439168..44e4773d 100644 --- a/.github/workflows/rust-ci.yaml +++ b/.github/workflows/rust-ci.yaml @@ -1,5 +1,8 @@ name: Rust CI +env: + SVDTOOLS: svdtools + on: push: branches: [ staging, trying, master ] @@ -13,7 +16,7 @@ jobs: RUSTFLAGS: "-D warnings" RUSTDOCFLAGS: "-D warnings" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -26,7 +29,7 @@ jobs: RUSTFLAGS: "-D warnings" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -38,7 +41,7 @@ jobs: RUSTFLAGS: "-D warnings" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -52,7 +55,7 @@ jobs: name: Clippy runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -65,7 +68,7 @@ jobs: name: Format runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -80,7 +83,7 @@ jobs: - stm32 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -92,4 +95,4 @@ jobs: run: | cargo install svdtools --path . - name: Check - run: env SVDTOOLS=svdtools bash tools/check_${{ matrix.target }}.sh + run: bash tools/check_${{ matrix.target }}.sh diff --git a/CHANGELOG-rust.md b/CHANGELOG-rust.md index 27b24387..cf4443b6 100644 --- a/CHANGELOG-rust.md +++ b/CHANGELOG-rust.md @@ -5,6 +5,7 @@ This changelog tracks the Rust `svdtools` project. See ## [Unreleased] +* Added action to build binaries and release for every version tag and latest commit * Use `svd-parser` 0.13.4, add `expand_properties` option in `convert` * `patch`: check enum `usage`, don't add it if unneeded