Skip to content

Commit

Permalink
Merge pull request #116 from stepchowfun/windows
Browse files Browse the repository at this point in the history
Add support for Windows and non-GNU Linux
  • Loading branch information
stepchowfun authored Jun 21, 2021
2 parents d30f181 + c5b40cc commit eead91a
Show file tree
Hide file tree
Showing 13 changed files with 412 additions and 149 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ A clear description of what the bug is.
**Instructions to reproduce the bug**
A clear explanation of how to reproduce the bug.

**System information:**
- OS: [e.g. macOS Mojave 10.14.5]
**Environment information:**
- Tagref version: [e.g. 0.0.0]
- OS: [e.g. macOS Big Sur 11.4 (20F71)]

**Additional context**
Add any other context about the problem here.
162 changes: 158 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,172 @@
name: Continuous integration
on: [push, pull_request]
defaults:
run:
shell: bash
jobs:
ci:
ci-linux:
name: Build and test on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: azure/docker-login@v1
- if: ${{ github.event_name == 'push' }}
uses: azure/docker-login@v1
with:
username: stephanmisc
password: ${{ secrets.DOCKER_PASSWORD }}
if: github.event_name == 'push'
- uses: stepchowfun/toast/.github/actions/toast@main
with:
tasks: build check test lint run
tasks: build test lint release run
repo: stephanmisc/toast
write_remote_cache: ${{ github.event_name == 'push' }}
- run: |
# Make Bash not silently ignore errors.
set -euo pipefail
# The artifact name will contain the target triple, so the file name doesn't need to.
mv artifacts/tagref-x86_64-unknown-linux-gnu artifacts/tagref
- uses: actions/upload-artifact@v2
with:
name: x86_64-unknown-linux-gnu
path: artifacts/tagref
if-no-files-found: error
- run: |
# Make Bash not silently ignore errors.
set -euo pipefail
# The artifact name will contain the target triple, so the file name doesn't need to.
mv artifacts/tagref-x86_64-unknown-linux-musl artifacts/tagref
- uses: actions/upload-artifact@v2
with:
name: x86_64-unknown-linux-musl
path: artifacts/tagref
if-no-files-found: error
ci-macos:
name: Build and test on macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- run: |
# Make Bash not silently ignore errors.
set -euo pipefail
rustup toolchain install 1.53.0 # [ref:rust_1_53_0]
rustup default 1.53.0 # [ref:rust_1_53_0]
- run: |
# Make Bash not silently ignore errors.
set -euo pipefail
# Build and test.
cargo build --locked --release --target x86_64-apple-darwin
NO_COLOR=true cargo test --locked # [ref:colorless_tests]
- uses: actions/upload-artifact@v2
with:
name: x86_64-apple-darwin
path: target/x86_64-apple-darwin/release/tagref
if-no-files-found: error
ci-windows:
name: Build and test on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- run: |
# Make Bash not silently ignore errors.
set -euo pipefail
rustup toolchain install 1.53.0 # [ref:rust_1_53_0]
rustup default 1.53.0 # [ref:rust_1_53_0]
- run: |
# Make Bash not silently ignore errors.
set -euo pipefail
# Build and test.
cargo build --locked --release --target x86_64-pc-windows-msvc
NO_COLOR=true cargo test --locked # [ref:colorless_tests]
- uses: actions/upload-artifact@v2
with:
name: x86_64-pc-windows-msvc
path: target/x86_64-pc-windows-msvc/release/tagref.exe
if-no-files-found: error
install-macos:
name: Run the installer script on macOS to validate it
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- run: |
# Make Bash not silently ignore errors.
set -euo pipefail
# Run the installer script.
PREFIX=/tmp ./install.sh
# Run the installed binary.
/tmp/tagref
install-ubuntu:
name: Run the installer script on Ubuntu to validate it
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
# Make Bash not silently ignore errors.
set -euo pipefail
# Run the installer script.
PREFIX=/tmp ./install.sh
# Run the installed binary.
/tmp/tagref
create-release:
name: Create a release on GitHub if applicable
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [ci-linux, ci-macos, ci-windows, install-macos, install-ubuntu]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: artifacts/
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Make Bash not silently ignore errors.
set -euo pipefail
# Fetch the program version.
VERSION="$(cargo pkgid | cut -d# -f2 | cut -d: -f2)"
# If the release already exists, exit early.
if hub release show "v$VERSION" &> /dev/null; then
echo "Release v$VERSION already exists."
exit
fi
# Give the artifacts unique names.
mv \
artifacts/x86_64-unknown-linux-gnu/tagref \
artifacts/tagref-x86_64-unknown-linux-gnu
mv \
artifacts/x86_64-unknown-linux-musl/tagref \
artifacts/tagref-x86_64-unknown-linux-musl
mv \
artifacts/x86_64-apple-darwin/tagref \
artifacts/tagref-x86_64-apple-darwin
mv \
artifacts/x86_64-pc-windows-msvc/tagref.exe \
artifacts/tagref-x86_64-pc-windows-msvc.exe
# Create the release.
hub release create \
--commitish '${{ github.sha }}' \
--message "v$VERSION" \
--attach 'artifacts/tagref-x86_64-unknown-linux-gnu' \
--attach 'artifacts/tagref-x86_64-unknown-linux-musl' \
--attach 'artifacts/tagref-x86_64-apple-darwin' \
--attach 'artifacts/tagref-x86_64-pc-windows-msvc.exe' \
"v$VERSION"
echo "Created release v$VERSION."
- uses: stepchowfun/toast/.github/actions/toast@main
with:
tasks: publish
repo: stephanmisc/toast
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# Keep this file in sync with `.ignore`.
/artifacts/
/release/
/target/
4 changes: 0 additions & 4 deletions .ignore

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.0] - 2021-06-20

### Added
- Tagref now supports two new platforms: (1) Windows, and (2) Linux without glibc.

## [1.4.1] - 2020-12-08

### Changed
Expand Down
42 changes: 42 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,45 @@
Thank you for your interest in contributing! You can contribute by filing [issues](https://github.com/stepchowfun/tagref/issues) and submitting [pull requests](https://github.com/stepchowfun/tagref/pulls). Please observe our [code of conduct](https://github.com/stepchowfun/tagref/blob/main/CODE_OF_CONDUCT.md).

If you submit a pull request, please ensure your change passes the [GitHub Actions](https://github.com/stepchowfun/tagref/actions) CI checks. This will be apparent from the required status check(s) in the pull request.

## Rust style guide

We are fortunate to have good tooling around enforcing a consistent style throughout the codebase. If you have [Toast](https://github.com/stepchowfun/toast), you can run the various lint checks by running `toast lint`. Otherwise, you can rely on our CI to do it for you. Here, we make note of a few conventions which are not yet enforced automatically. Please adhere to these conventions when possible, and provide appropriate justification for deviations from this guide. If you notice any style violations which appear unintentional, we invite you to bring them to our attention.

### Comments

**Rule:** Comments should be written in American English.

**Rule:** Comments should always be capitalized unless they start with a code-like expression (see below).

**Rule:** Comments which are sentences should be punctuated appropriately. For example:

```rust
// The following logic implements beta reduction.
```

**Rule:** Comments which are not sentences should not have a trailing period. For example:

```rust
// Already normalized
```

**Rule:** Code-like expressions, such as variable names, should be surrounded by backticks. For example:

```rust
// `source_range` is a half-open interval, closed on the left and open on the right.
```

### Trailing commas

The linter enforces that items in multi-line sequences (e.g., function arguments and macro arguments) have trailing commas.

**Rule:** Macros should be written to accept trailing commas as follows:

```rust
macro_rules! my_macro {
($foo:expr, $bar:expr, $baz:expr $(,)?) => {{
...
}};
}
```
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tagref"
version = "1.4.1"
version = "1.5.0"
authors = ["Stephan Boyer <stephan@stephanboyer.com>"]
edition = "2018"
description = "Tagref helps you refer to other locations in your codebase."
Expand Down
32 changes: 32 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Maintainers

This document describes some instructions for maintainers. Other contributors and users need not be concerned with this material.

### GitHub instructions

When setting up the repository on GitHub, configure the following settings:

- Under `Secrets`, add the following repository secrets with appropriate values:
- `CRATES_IO_TOKEN`
- `DOCKER_PASSWORD`
- Under `Branches`, add a branch protection rule for the `main` branch.
- Enable `Require status checks to pass before merging`.
- Enable `Require branches to be up to date before merging`.
- Add the following status checks:
- `Build and test on Linux`
- `Build and test on Windows`
- `Build and test on macOS`
- `Create a release on GitHub if applicable`
- `Run the installer script on Ubuntu to validate it`
- `Run the installer script on macOS to validate it`
- Enable `Include administrators`.
- Under `Options`, enable `Automatically delete head branches`.

The GitHub workflow will fail initially because the jobs which test the installer script will not find any release to download. You'll need to bootstrap a release by temporarily removing those jobs or changing them to no-ops. Be aware that the `create-release` job is configured to only run on the `main` branch, so you may also need to temporarily change that depending on which branch you're working on.

### Release instructions

Releasing a new version is a two-step process:

1. Bump the version in `Cargo.toml`, run `cargo build` to update `Cargo.lock`, and update `CHANGELOG.md` with information about the new version. Ship those changes as a single commit.
2. Once the GitHub workflow has finished on the `main` branch, update the version in `install.sh` to point to the new release.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ SUBCOMMANDS:
Lists the unreferenced tags
```

## Installation
## Installation instructions

### Easy installation
### Easy installation on macOS or Linux

If you are running macOS or a GNU-based Linux on an x86-64 CPU, you can install Tagref with this command:
If you are running macOS or Linux on an x86-64 CPU, you can install Tagref with this command:

```sh
curl https://raw.githubusercontent.com/stepchowfun/tagref/main/install.sh -LSfs | sh
```

The same command can be used again to update Tagref to the latest version.

**NOTE:** Piping `curl` to `sh` is dangerous since the server might be compromised. If you're concerned about this, you can download and inspect the installation script or choose one of the other installation methods.
**NOTE:** Piping `curl` to `sh` is considered dangerous by some since the server might be compromised. If you're concerned about this, you can download and inspect the installation script or choose one of the other installation methods.

#### Customizing the installation

Expand All @@ -116,9 +116,9 @@ For example, the following will install Tagref into the working directory:
curl https://raw.githubusercontent.com/stepchowfun/tagref/main/install.sh -LSfs | PREFIX=. sh
```

### Manual installation
### Manual installation for macOS, Linux, or Windows

The [releases page](https://github.com/stepchowfun/tagref/releases) has precompiled binaries for macOS or Linux systems running on an x86-64 CPU. You can download one of them and place it in a directory listed in your [`PATH`](https://en.wikipedia.org/wiki/PATH_\(variable\)).
The [releases page](https://github.com/stepchowfun/tagref/releases) has precompiled binaries for macOS, Linux, and Windows systems running on an x86-64 CPU. You can download one of them and place it in a directory listed in your [`PATH`](https://en.wikipedia.org/wiki/PATH_\(variable\)).

### Installation with Cargo

Expand Down
Loading

0 comments on commit eead91a

Please sign in to comment.