Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to CLI v3 #304

Merged
merged 23 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/changelog-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"categories": [
{
"title": "## Changes",
"labels": [],
"exhaustive": false
}
],
"template": "${{CHANGELOG}}\n",
"pr_template": "- #${{NUMBER}} ${{TITLE}}"
}
43 changes: 0 additions & 43 deletions .github/workflows/build.yml

This file was deleted.

88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
on:
push:
branches:
- main
pull_request:
branches:
- main

name: CI

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v2

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
# Set linting rules for clippy
args: --all-targets

test-plan:
name: Tests
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
outputs:
matrix: ${{ steps.docker-prep.outputs.matrix }}
if: "!contains(github.event.head_commit.message, '(cargo-release)')"
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v2

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
4 changes: 2 additions & 2 deletions .github/workflows/label-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
- uses: jesusvasquez333/verify-pr-label-action@v1.4.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
valid-labels: "release/patch, release/minor, release/major"
pull-request-number: '${{ github.event.pull_request.number }}'
valid-labels: "release/patch, release/minor, release/major, release/skip"
ndneighbor marked this conversation as resolved.
Show resolved Hide resolved
pull-request-number: "${{ github.event.pull_request.number }}"
disable-reviews: true
90 changes: 0 additions & 90 deletions .github/workflows/publish.yml

This file was deleted.

154 changes: 154 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Release
on:
push:
tags:
- "v*.*.*"
env:
MACOSX_DEPLOYMENT_TARGET: 10.7

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
rlwy_version: ${{ env.CLI_VERSION }}

steps:
- name: Get the release version from the tag
shell: bash
if: env.CLI_VERSION == ''
run: |
# Apparently, this is the right way to get a tag name. Really?
nebulatgs marked this conversation as resolved.
Show resolved Hide resolved
#
# See: https://github.saobby.my.eu.orgmunity/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "CLI_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.CLI_VERSION }}"

- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v3.7.0
with:
configuration: ".github/changelog-configuration.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub release
id: release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.CLI_VERSION }}
release_name: ${{ env.CLI_VERSION }}

build-release:
name: Build Release Assets
needs: ["create-release"]
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest

- target: x86_64-unknown-linux-musl
os: ubuntu-latest

- target: i686-unknown-linux-musl
os: ubuntu-latest

- target: aarch64-unknown-linux-musl
os: ubuntu-latest

- target: arm-unknown-linux-musleabihf
os: ubuntu-latest

- target: x86_64-apple-darwin
os: macOS-latest

- target: aarch64-apple-darwin
os: macOS-latest

- target: x86_64-pc-windows-msvc
os: windows-latest

- target: i686-pc-windows-msvc
os: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
override: true

- name: Build release binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target ${{ matrix.target }}
use-cross: ${{ matrix.os == 'ubuntu-latest' }}

- name: Prepare binaries [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip rlwy.exe
7z a ../../../rlwy-${{ needs.create-release.outputs.rlwy_version }}-${{ matrix.target }}.zip rlwy.exe
cd -

- name: Prepare binaries [-linux]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip rlwy || true
tar czvf ../../../rlwy-${{ needs.create-release.outputs.rlwy_version }}-${{ matrix.target }}.tar.gz rlwy
cd -

- name: Upload release archive
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create-release.outputs.rlwy_version }}
files: rlwy-${{ needs.create-release.outputs.rlwy_version }}-${{ matrix.target }}*

- name: Install cargo-deb
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo install cargo-deb

- name: Generate .deb package file
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo deb --target x86_64-unknown-linux-musl --output rlwy-${{ needs.create-release.outputs.rlwy_version }}-amd64.deb

- name: Upload .deb package file
if: matrix.target == 'x86_64-unknown-linux-musl'
uses: svenstaro/upload-release-action@v2
with:
tag: ${{ needs.create-release.outputs.rlwy_version }}
file: rlwy-${{ needs.create-release.outputs.rlwy_version }}-amd64.deb

- name: Update homebrew tap
uses: mislav/bump-homebrew-formula-action@v2
if: "matrix.target == 'x86_64-apple-darwin' || matrix.target == 'aarch64-apple-darwin' && !contains(github.ref, '-')"
with:
formula-name: rlwy
formula-path: rlwy.rb
homebrew-tap: railwayapp/homebrew-tap
download-url: https://github.com/railwayapp/cli/releases/latest/download/rlwy-${{ needs.create-release.outputs.rlwy_version }}-${{ matrix.target }}.tar.gz
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
Loading