feat(setup-versioned-files-action): Create github action #18
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: Pipeline | |
on: | |
push: | |
branches: | |
- '*' | |
pull_request: | |
permissions: | |
contents: write | |
jobs: | |
run-tests: | |
uses: ./.github/workflows/run-tests.yml | |
bump-cargo-version: | |
runs-on: ubuntu-latest | |
needs: | |
- run-tests | |
if: github.ref == 'refs/heads/main' && needs.run-tests.outputs.will-bump == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout the repository | |
- uses: actions/cache@v3.3.2 | |
name: Cache cargo dependencies | |
with: | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
path: | | |
.cache | |
~/.cargo/registry | |
~/.cargo/git | |
~/.cargo/bin | |
target | |
- uses: actions-rs/toolchain@v1.0.7 | |
name: Install rust toolchain | |
with: | |
default: true | |
profile: minimal | |
toolchain: stable | |
- uses: actions-rs/cargo@v1.0.3 | |
name: Build release version | |
with: | |
args: --release --locked | |
command: build | |
- name: Install cargo-edit | |
run: cargo install cargo-edit | |
- name: Set Cargo version | |
run: cargo set-version "${NEW_VERSION#v}" | |
env: | |
NEW_VERSION: ${{ needs.run-tests.outputs.bump-version }} | |
- name: Store updated Cargo files | |
uses: actions/upload-artifact@v3 | |
with: | |
name: bumped-files | |
path: Cargo.* | |
build-binaries: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ${{ matrix.os }} | |
needs: | |
- run-tests | |
steps: | |
- run: ${{ matrix.install }} | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
name: Install additional dependencies | |
- uses: actions/checkout@v4 | |
name: Checkout the repository | |
- uses: actions/cache@v3.3.2 | |
name: Cache cargo dependencies | |
with: | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
path: | | |
.cache | |
~/.cargo/registry | |
~/.cargo/git | |
~/.cargo/bin | |
target | |
- uses: actions-rs/toolchain@v1.0.7 | |
name: Install rust toolchain | |
with: | |
default: true | |
profile: minimal | |
toolchain: stable | |
- uses: actions-rs/cargo@v1.0.3 | |
name: Build release version | |
with: | |
args: --release --locked | |
command: build | |
- id: get_repository_name | |
name: Calculate repository name | |
run: echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk | |
-F / '{print $2}' | sed -e "s/:refs//")" >> "$GITHUB_OUTPUT" | |
shell: bash | |
- name: Move binary to upload location | |
env: | |
TARGET: ${{ matrix.target }} | |
EXTENSION: ${{ matrix.suffix }} | |
REPOSITORY_NAME: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }} | |
run: mv "./target/release/$REPOSITORY_NAME$EXTENSION" "./$REPOSITORY_NAME-$TARGET$EXTENSION" | |
shell: bash | |
- uses: actions/upload-artifact@v3 | |
name: Store built binary version | |
with: | |
name: bins | |
path: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-${{ matrix.target }}${{ matrix.suffix }} | |
strategy: | |
matrix: | |
include: | |
- os: macos-latest | |
suffix: '' | |
target: x86_64-apple-darwin | |
install: '' | |
- os: ubuntu-latest | |
suffix: '' | |
target: x86_64-unknown-linux-gnu | |
install: '' | |
- os: windows-latest | |
suffix: .exe | |
target: x86_64-pc-windows-msvc | |
install: '' | |
tag-and-release: | |
needs: | |
- build-binaries | |
- bump-cargo-version | |
uses: armakuni/github-actions/.github/workflows/tag-and-release.yml@v0.18.1 | |
with: | |
download-artifacts: true | |
release-artifacts: ./bins/* | |