-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from stepchowfun/windows
Add support for Windows and non-GNU Linux
- Loading branch information
Showing
13 changed files
with
412 additions
and
149 deletions.
There are no files selected for viewing
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
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
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 }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
# Keep this file in sync with `.ignore`. | ||
/artifacts/ | ||
/release/ | ||
/target/ |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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. |
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
Oops, something went wrong.