Skip to content

Commit fdac710

Browse files
committed
ci: Switch to GitHub CI (and configure M1 Mac builds)
1 parent f358313 commit fdac710

File tree

5 files changed

+171
-87
lines changed

5 files changed

+171
-87
lines changed

.github/workflows/ci.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: CI
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull
4+
# request events but only for the main branch.
5+
on:
6+
push:
7+
# Run on the main branch.
8+
branches:
9+
- main
10+
- ci
11+
tags:
12+
- "v*"
13+
pull_request:
14+
# Only run on pull requests against main.
15+
branches: [main]
16+
17+
jobs:
18+
# We run this job first, to create any GitHub release that we might need.
19+
# Creating a release can only be done once, so we need to split it out from
20+
# other jobs.
21+
create_release:
22+
name: Create release (if needed)
23+
runs-on: ubuntu-latest
24+
outputs:
25+
release_version: ${{ steps.extract_release_version.outputs.release_version }}
26+
upload_url: ${{ steps.create_release.outputs.upload_url }}
27+
steps:
28+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
29+
- uses: actions/checkout@v2
30+
- name: Extract release version
31+
id: extract_release_version
32+
run: |
33+
release_version="$(echo '${{ github.ref }}' | sed 's,^.*/\([^/]*\)$,\1,; s,^v,,' )"
34+
echo Release version: $release_version
35+
echo "::set-output name=release_version::$release_version"
36+
- name: Extract release body from CHANGELOG.md
37+
id: extract_release_body
38+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
39+
# Use `clparse` to parse `CHANGELOG.md` and extract release notes.
40+
run: |
41+
curl -sLO https://github.com/marcaddeo/clparse/releases/download/0.8.0/clparse-0.8.0-x86_64-unknown-linux-musl.tar.gz
42+
tar xzf clparse*.tar.gz
43+
sudo cp clparse /usr/local/bin
44+
rm -rf clparse*
45+
clparse -f json CHANGELOG.md | \
46+
jq ".releases[] | select(.version == \"${{ steps.extract_release_version.outputs.release_version }}\") | { title: \"\", description: \"\", releases: [.] }" | \
47+
clparse - | \
48+
tail -n +3 > RELEASE_BODY.md
49+
- name: "Make release"
50+
id: create_release
51+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
52+
uses: actions/create-release@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
tag_name: ${{ github.ref }}
57+
release_name: "${{ steps.extract_release_version.outputs.release_version }}"
58+
body_path: RELEASE_BODY.md
59+
60+
# We use a matrix to run our build on every supported platform.
61+
build:
62+
name: "Build"
63+
64+
needs:
65+
- create_release
66+
67+
strategy:
68+
matrix:
69+
# target: Official name of system to compile for.
70+
# host: Official name of system doing the compiling.
71+
# cargo: Should we use regular cargo, or the cross wrapper for cross-compiling?
72+
# os: GitHub CI OS image to use on runner.
73+
include:
74+
- target: x86_64-unknown-linux-musl
75+
host: x86_64-unknown-linux-musl
76+
cargo: cross
77+
os: ubuntu-latest
78+
- target: x86_64-apple-darwin
79+
host: x86_64-apple-darwin
80+
cargo: cargo
81+
os: macos-latest
82+
- target: aarch64-apple-darwin
83+
host: x86_64-apple-darwin
84+
cargo: cargo
85+
os: macos-latest
86+
87+
runs-on: ${{ matrix.os }}
88+
89+
steps:
90+
- name: Install Rust toolchain
91+
uses: actions-rs/toolchain@v1
92+
with:
93+
profile: minimal
94+
# We track latest stable Rust instead of hardcoding it because it
95+
# virtually never breaks old code.
96+
toolchain: stable
97+
components: rustfmt, clippy
98+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
99+
- uses: actions/checkout@v2
100+
- name: Check source formatting and warnings
101+
run: |
102+
cargo fmt -- --check
103+
cargo clippy -- -D warnings
104+
- name: Check policy
105+
run: |
106+
version=0.11.0
107+
basename=cargo-deny-$version-${{ matrix.host }}
108+
curl -fLO https://github.com/EmbarkStudios/cargo-deny/releases/download/$version/$basename.tar.gz
109+
tar xf $basename.tar.gz
110+
mv $basename/cargo-deny /usr/local/bin/
111+
rm -rf $basename $basename.tar.gz
112+
cargo deny check
113+
- name: Test
114+
run: |
115+
cargo test
116+
- name: Install cargo cross (if needed)
117+
if: ${{ matrix.cargo == 'cross' }}
118+
# Note that this will not work for Rust programs using openssl or libpq.
119+
run: |
120+
version=v0.2.1
121+
basename=cross-$version-${{ matrix.host }}
122+
curl -fLO https://github.com/rust-embedded/cross/releases/download/$version/$basename.tar.gz
123+
tar xf $basename.tar.gz
124+
mv cross /usr/local/bin/
125+
rm -rf $basename.tar.gz
126+
- name: Build binaries
127+
run: |
128+
${{ matrix.cargo }} build --release --target ${{ matrix.target }}
129+
# If we have a code-signing identity, we could use it like this.
130+
#
131+
# - name: Sign binaries (if needed)
132+
# if: ${{ contains(matrix.target, 'apple') }}
133+
# run: |
134+
# codesign --force -s $YOUR_IDENTITY_HERE target/${{ matrix.target }}/release/geocode-csv
135+
- name: Build release
136+
id: build_release
137+
run: |
138+
release_file=geocode-csv-${{ matrix.target }}-${{ needs.create_release.outputs.release_version }}.zip
139+
zip -j $release_file target/${{ matrix.target }}/release/geocode-csv
140+
echo "::set-output name=release_file::$release_file"
141+
- name: Upload Release Asset
142+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
143+
uses: actions/upload-release-asset@v1
144+
env:
145+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146+
with:
147+
upload_url: ${{ needs.create_release.outputs.upload_url }}
148+
asset_path: ./${{ steps.build_release.outputs.release_file }}
149+
asset_name: ${{ steps.build_release.outputs.release_file }}
150+
asset_content_type: application/zip

.travis.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ All notable changes to this project will be documented in this file.
44

55
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).
66

7-
## [Unreleased]
8-
97
## [1.0.0] - 2021-12-13
108

119
Bumping number to v1.0.0 because this has been running fine in production for quite.

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Resident,1600 Pennsylvania Avenue NW,,Washington DC,20500
1515

1616
```json
1717
{
18-
"geocoded": {
19-
"street": ["street1", "street2"],
20-
"city": "city",
21-
"state": "state",
22-
"zipcode": "zip"
23-
}
18+
"geocoded": {
19+
"street": ["street1", "street2"],
20+
"city": "city",
21+
"state": "state",
22+
"zipcode": "zip"
23+
}
2424
}
2525
```
2626

@@ -41,11 +41,23 @@ You can geocode multiple addresses per row as follows:
4141

4242
```json
4343
{
44-
"geocoded_shipping": { /* ... */ },
45-
"geocoded_billing": { /* ... */ }
44+
"geocoded_shipping": {
45+
/* ... */
46+
},
47+
"geocoded_billing": {
48+
/* ... */
49+
}
4650
}
4751
```
4852

4953
This will insert two sets of columns, one beginning with `geocoded_shipping_` and the other with `geocoded_billing_`.
5054

51-
[SmartyStreets]: https://smartystreets.com/
55+
## A note about Macs
56+
57+
We provide pre-built Mac binaries for Intel- and M1-based Macs. These binaries use "ad-hoc" signatures, so you may need to [set appropriate security settings](https://support.apple.com/en-us/HT202491) or run:
58+
59+
```sh
60+
xattr -d com.apple.quarantine geocode-csv
61+
```
62+
63+
[smartystreets]: https://smartystreets.com/

build-release

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)