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

Fix CI #489

Closed
wants to merge 13 commits into from
Closed
12 changes: 5 additions & 7 deletions .github/workflows/cargo-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ on:
jobs:
security_audit:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: checkout
uses: actions/[email protected]

- name: cargo audit
uses: actions-rs/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- uses: actions-rust-lang/audit@v1
87 changes: 21 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,80 +9,35 @@ on:
name: CI

jobs:
check:
rust:
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 --all-features
- name: checkout
uses: actions/checkout@v4
- name: install rust
uses: dtolnay/rust-toolchain@stable
- name: cache dependencies
uses: Swatinem/rust-cache@v2
- name: check formatting
run: cargo fmt --all -- --check
- name: cargo check
run: cargo check --workspace --locked
- name: clippy
run: cargo clippy --all-targets --all-features

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
- name: checkout
uses: actions/checkout@v4
- name: install rust
uses: dtolnay/rust-toolchain@stable
- name: cache dependencies
uses: Swatinem/rust-cache@v2
- name: test
run: cargo test
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Install the cosign tool
# https://github.com/sigstore/cosign-installer
Expand Down
188 changes: 88 additions & 100 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,16 @@
name: Release
name: Deploy
on:
push:
tags:
- "v*.*.*"
- "v*"

env:
MACOSX_DEPLOYMENT_TARGET: 10.7
CARGO_INCREMENTAL: 0

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
railway_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?
#
# See: https://github.community/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/[email protected]
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 }}
name: ${{ env.CLI_VERSION }}

build-release:
name: Build Release Assets
needs: ["create-release"]
runs-on: ${{ matrix.os }}
# Build sources for every OS
github_build:
name: Build release binaries
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -81,89 +42,116 @@ jobs:
- target: i686-pc-windows-msvc
os: windows-latest

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

- target: i686-pc-windows-gnu
- target: x86_64-unknown-freebsd
os: ubuntu-latest
use-cross: true

runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
- name: Checkout repository
- name: Setup | Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

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

- name: Setup | Cache
uses: Swatinem/rust-cache@v2


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

- name: Prepare binaries (zip) [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip railway.exe
7z a ../../../railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}.zip railway.exe
cd -
- name: Get Version
id: version
run: echo ::set-output name=version::$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')

- name: Prepare binaries (tar) [Windows]
- name: Post Build | Prepare artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip railway.exe
7z a -ttar archive.tar railway.exe
7z a -tgzip ../../../railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}.tar.gz archive.tar
version=${{ steps.version.outputs.version }}
7z a ../../../railway-${{ steps.version.outputs.version }}-${{ matrix.target }}.zip railway.exe
cd -

- name: Prepare binaries [-linux]
- name: Post Build | Prepare artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
# TODO: investigate better cross platform stripping
strip railway || true
tar czvf ../../../railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}.tar.gz railway
tar czvf ../../../railway-${{ steps.version.outputs.version }}-${{ matrix.target }}.tar.gz railway
cd -

- name: Upload release archive
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create-release.outputs.railway_version }}
files: railway-${{ needs.create-release.outputs.railway_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 railway-${{ needs.create-release.outputs.railway_version }}-amd64.deb
- name: Build | Create Debian package
if: matrix.os == 'ubuntu-latest'
run: |
version=${{ steps.version.outputs.version }}
cargo install cargo-deb
cargo deb --no-build --target ${{ matrix.target }}
mv target/${{ matrix.target }}/debian/railway_${{ steps.version.outputs.version }}_${{ matrix.target }}.deb railway-${{ steps.version.outputs.version }}-${{ matrix.target }}.deb

- name: Upload .deb package file
if: matrix.target == 'x86_64-unknown-linux-musl'
uses: svenstaro/upload-release-action@v2
- name: Deploy | Upload artifacts
uses: actions/upload-artifact@v3
with:
tag: ${{ needs.create-release.outputs.railway_version }}
file: railway-${{ needs.create-release.outputs.railway_version }}-amd64.deb

name: railway-${{ steps.version.outputs.version }}-${{ matrix.target }}
path: |
railway-${{ steps.version.outputs.version }}-${{ matrix.target }}.*
target/${{ matrix.target }}/debian/*.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, '-')"
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/railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}.tar.gz
formula-name: rlwy
formula-path: rlwy.rb
homebrew-tap: railwayapp/homebrew-tap
download-url: https://github.com/railwayapp/cli/releases/latest/download/railway-${{ steps.version.outputs.version }}-${{ matrix.target }}.tar.gz
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}

# Create GitHub release with Rust build targets
github_release:
name: Create GitHub Release
needs: github_build
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup | Artifacts
uses: actions/download-artifact@v3

- name: Build | Publish
uses: softprops/action-gh-release@v1
with:
files: |
railway-*/railway-*
railway-*/railway-*.deb

# Publish to crates.io and bump Homebrew formula
publish:
name: Publish to crates.io and Bump Homebrew Formula
needs: github_release
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v3

- name: Setup | Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
uses: katyo/publish-crates@v2
with:
token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
node_modules
bin/railway
bin/railway
.DS_Store
3 changes: 1 addition & 2 deletions npm-install/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ export const CONFIG = {
* - `{{arch}}` is one of the Golang achitectures listed below
* - `{{bin_name}}` is the name declared above
* - `{{platform}}` is one of the Golang platforms listed below
* - `{{version}}` is the version number as `0.0.0` (taken from package.json)
*
* @type {string}
*/
url: "https://github.com/railwayapp/cli/releases/download/v{{version}}/{{bin_name}}-v{{version}}-{{triple}}.tar.gz",
url: "https://github.com/railwayapp/cli/releases/download/v{{version}}/{{bin_name}}-{{triple}}.tar.gz",
};