feat: add backend boilerplate #1
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
# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
on: | ||
workflow_call: | ||
name: Semantic Release | ||
env: | ||
RUST_BACKTRACE: 1 | ||
SEMREL_RUST_VERSION: 2.1.53 | ||
concurrency: | ||
group: ${{ github.workflow }} | ||
jobs: | ||
build_application: | ||
name: Build CLI ${{ matrix.build.target }} | ||
runs-on: ${{ matrix.build.os }} | ||
env: | ||
CARGO: cargo | ||
strategy: | ||
matrix: | ||
bin: | ||
- {{project-name}} | ||
build: | ||
# alphabatized by target | ||
- os: macOS-latest | ||
target: aarch64-apple-darwin | ||
cross: true | ||
- os: ubuntu-latest | ||
target: aarch64-unknown-linux-gnu | ||
cross: true | ||
- os: ubuntu-latest | ||
target: aarch64-unknown-linux-musl | ||
cross: true | ||
- os: ubuntu-latest | ||
target: i686-unknown-linux-gnu | ||
cross: true | ||
- os: ubuntu-latest | ||
target: i686-unknown-linux-musl | ||
cross: true | ||
- os: macOS-latest | ||
target: x86_64-apple-darwin | ||
cross: false | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
cross: false | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-musl | ||
cross: false | ||
- os: ubuntu-latest | ||
target: x86_64-pc-windows-gnu | ||
cross: true | ||
- os: ubuntu-latest | ||
target: i686-pc-windows-gnu | ||
cross: true | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
- name: Install tree | ||
if: runner.os == 'Linux' | ||
run: sudo apt install tree | ||
- name: Install build inputs | ||
if: runner.os == 'Linux' && !matrix.build.cross | ||
run: sudo apt install musl-tools mingw-w64 | ||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
id: rust-toolchain | ||
with: | ||
toolchain: stable | ||
target: ${{ matrix.build.target }} | ||
- name: Cache dependencies | ||
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1 | ||
- name: Install cross | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cross | ||
- name: Configure cross | ||
if: matrix.build.cross | ||
run: echo "CARGO=cross" >> "$GITHUB_ENV" | ||
- name: Compile release binary | ||
run: ${{ env.CARGO }} build --bin ${{ matrix.bin }} --release --target ${{ matrix.build.target }} --verbose | ||
- name: Show generated binary | ||
if: runner.os == 'Linux' | ||
run: tree target/ | ||
- name: Create release archive - windows | ||
if: matrix.build.target == 'x86_64-pc-windows-gnu' || matrix.build.target == 'i686-pc-windows-gnu' | ||
run: | | ||
mkdir dist | ||
cp target/${{ matrix.build.target }}/release/${{ matrix.bin }}.exe dist/${{ matrix.bin }}-${{ matrix.build.target }} | ||
- name: Create release archive - non-windows | ||
if: matrix.build.target != 'x86_64-pc-windows-gnu' && matrix.build.target != 'i686-pc-windows-gnu' | ||
run: | | ||
mkdir dist | ||
cp target/${{ matrix.build.target }}/release/${{ matrix.bin }} dist/${{ matrix.bin }}-${{ matrix.build.target }} | ||
- name: Create binary checksum | ||
run: | | ||
shasum --algorithm 256 \ | ||
--binary ${{ matrix.bin }}-${{ matrix.build.target }} | tee ${{ matrix.bin }}-${{ matrix.build.target }}-SHA256SUM.txt | ||
working-directory: ./dist | ||
- name: Upload release artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.build.target }} | ||
path: | | ||
dist/${{ matrix.bin }}-${{ matrix.build.target }} | ||
dist/${{ matrix.bin }}-${{ matrix.build.target }}-SHA256SUM.txt | ||
if-no-files-found: error | ||
retention-days: 1 | ||
release: | ||
name: Semantic Release | ||
runs-on: ubuntu-latest | ||
needs: build_application | ||
outputs: | ||
new_release_version: ${{steps.semantic.outputs.new_release_version}} | ||
new_release_published: ${{steps.semantic.outputs.new_release_published}} | ||
new_release_notes: ${{steps.semantic.outputs.new_release_notes}} | ||
new_release_channel: ${{steps.semantic.outputs.new_release_channel}} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }} | ||
fingerprint: ${{ secrets.GPG_SUBKEY_FINGERPRINT }} | ||
trust_level: 5 | ||
git_user_signingkey: true | ||
git_commit_gpgsign: true | ||
git_tag_gpgsign: false | ||
git_committer_name: ${{ vars.GIT_AUTHOR_NAME }} | ||
git_committer_email: ${{ vars.GIT_AUTHOR_EMAIL }} | ||
- name: Test GPG Key Import | ||
run: gpg --list-keys --keyid-format LONG | ||
- name: Install dependencies | ||
run: sudo apt install tree | ||
- name: Install semantic-release-cargo | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: semantic-release-cargo@${{env.SEMREL_RUST_VERSION}} | ||
- name: Download release artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: artifacts | ||
- name: ls artifacts | ||
run: tree ./artifacts | ||
- name: Prepare GitHub Release artifacts | ||
run: | | ||
mkdir dist/ | ||
mv -v artifacts/aarch64-apple-darwin dist/ | ||
mv -v artifacts/aarch64-unknown-linux-gnu dist/ | ||
mv -v artifacts/aarch64-unknown-linux-musl dist/ | ||
mv -v artifacts/i686-unknown-linux-gnu dist/ | ||
mv -v artifacts/i686-unknown-linux-musl dist/ | ||
mv -v artifacts/x86_64-apple-darwin dist/ | ||
mv -v artifacts/x86_64-unknown-linux-gnu dist/ | ||
mv -v artifacts/x86_64-unknown-linux-musl dist/ | ||
mv -v artifacts/x86_64-pc-windows-gnu dist/ | ||
mv -v artifacts/i686-pc-windows-gnu dist/ | ||
- name: Combine checksums | ||
run: cat dist/**/*-SHA256SUM.txt | tee dist/SHA256SUMS.txt | ||
- name: Install Conventional Commit preset | ||
run: npm install conventional-changelog-conventionalcommits | ||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@61680d0e9b02ff86f5648ade99e01be17f0260a4 # v4.0.0 | ||
id: semantic | ||
with: | ||
semantic_version: 22.0.3 | ||
extra_plugins: | | ||
@semantic-release/exec@6 | ||
@semantic-release/git@10 | ||
env: | ||
GITHUB_TOKEN: ${{secrets.ACTIONS_PAT_GITHUB}} | ||
CARGO_REGISTRY_TOKEN: ${{secrets.SEMREL_CRATES_IO}} | ||
GIT_AUTHOR_NAME: ${{vars.GIT_AUTHOR_NAME}} | ||
GIT_AUTHOR_EMAIL: ${{vars.GIT_AUTHOR_EMAIL}} |