Skip to content

Commit 63ba5f8

Browse files
committed
Add some basic CI and metadata
Turns out 3 years is awhile since this was last published. Let's try to modernize things a bit
1 parent 5b4b622 commit 63ba5f8

File tree

6 files changed

+263
-8
lines changed

6 files changed

+263
-8
lines changed

.github/dependabot.yml

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

.github/workflows/main.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
5+
defaults:
6+
run:
7+
shell: bash
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
include:
16+
- os: ubuntu-latest
17+
- os: macos-latest
18+
- os: macos-latest
19+
- os: windows-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: true
24+
- run: cargo test
25+
26+
msrv:
27+
name: MSRV
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
submodules: true
33+
- run: rustup update 1.60.0 && rustup default 1.60.0
34+
- run: cargo test
35+

.github/workflows/playground.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build playground
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
merge_group:
7+
8+
# Cancel any in-flight jobs for the same PR/branch so there's only one active
9+
# at a time
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
jobs:
19+
build:
20+
name: Build playground deployment
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
submodules: true
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
30+
- uses: cargo-bins/[email protected]
31+
- run: cargo binstall cargo-component -y
32+
- run: rustup component add rustfmt # needed for cargo-component, apparently?
33+
- run: rustup target add wasm32-wasip1
34+
- run: npm ci
35+
working-directory: playground
36+
- run: npm run build
37+
working-directory: playground
38+
39+
# also prepare to deploy GH pages on main
40+
- if: github.ref == 'refs/heads/main'
41+
uses: actions/configure-pages@v5
42+
- if: github.ref == 'refs/heads/main'
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: "./playground/dist"
46+
47+
deploy:
48+
name: Deploy playground
49+
if: github.ref == 'refs/heads/main'
50+
needs: build
51+
permissions:
52+
pages: write
53+
id-token: write
54+
runs-on: ubuntu-latest
55+
environment:
56+
name: github-pages
57+
url: ${{ steps.deployment.outputs.page_url }}
58+
steps:
59+
- id: deployment
60+
uses: actions/deploy-pages@v4

.github/workflows/publish.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Publication half of the release process for this repository. This runs on
2+
# pushes to `main` and will detect a magical string in commit messages. When
3+
# found a tag will be created, pushed, and then everything is published.
4+
5+
name: Publish Artifacts
6+
on:
7+
push:
8+
branches: [main]
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
create_tag:
15+
name: Publish artifacts of build
16+
runs-on: ubuntu-latest
17+
if: |
18+
github.repository_owner == 'bytecodealliance'
19+
&& github.event_name == 'push'
20+
&& github.ref == 'refs/heads/main'
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
fetch-depth: 0
26+
27+
- run: rustup update stable && rustup default stable
28+
29+
# If this is a push to `main` see if the push has an indicator saying that
30+
# a tag should be made. If so create one and push it.
31+
- name: Test if tag is needed
32+
run: |
33+
git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log
34+
version=$(./ci/print-current-version.sh)
35+
echo "version: $version"
36+
echo "version=$version" >> $GITHUB_OUTPUT
37+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
38+
if grep -q "automatically-tag-and-release-this-commit" main.log; then
39+
echo push-tag
40+
echo "push_tag=yes" >> $GITHUB_OUTPUT
41+
else
42+
echo no-push-tag
43+
echo "push_tag=no" >> $GITHUB_OUTPUT
44+
fi
45+
id: tag
46+
47+
- name: Push the tag
48+
run: |
49+
git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g')
50+
curl -iX POST $git_refs_url \
51+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
52+
-d @- << EOF
53+
{
54+
"ref": "refs/tags/v${{ steps.tag.outputs.version }}",
55+
"sha": "${{ steps.tag.outputs.sha }}"
56+
}
57+
EOF
58+
if: steps.tag.outputs.push_tag == 'yes'
59+
60+
- run: |
61+
sha=${{ github.sha }}
62+
run_id=$(
63+
gh api -H 'Accept: application/vnd.github+json' \
64+
/repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \
65+
| jq '.workflow_runs' \
66+
| jq "map(select(.head_commit.id == \"$sha\"))[0].id" \
67+
)
68+
gh run download $run_id
69+
ls
70+
find bins-*
71+
mkdir dist
72+
mv bins-*/* dist
73+
env:
74+
GH_TOKEN: ${{ github.token }}
75+
76+
- uses: softprops/action-gh-release@v1
77+
if: steps.tag.outputs.push_tag == 'yes'
78+
with:
79+
files: "dist/*"
80+
generate_release_notes: true
81+
tag_name: v${{ steps.tag.outputs.version }}
82+
83+
- run: |
84+
rm -rf dist main.log
85+
rustc ci/publish.rs
86+
./publish publish
87+
env:
88+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
89+
if: steps.tag.outputs.push_tag == 'yes'
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Initiation half of the release process for this repository.
2+
#
3+
# This is triggered manually through the github actions UI and will execute
4+
# `./publish bump` (or `bump-patch`). Afterwards the result will be pushed to a
5+
# branch in the main repository and a PR will be opened. This PR, when merged,
6+
# will trigger the second half in `publish.yml`.
7+
8+
name: "Automated Release Process"
9+
on:
10+
# Allow manually triggering this request via the button on the action
11+
# workflow page.
12+
workflow_dispatch:
13+
inputs:
14+
action:
15+
description: 'Publish script argument: "bump", or "bump-patch"'
16+
required: false
17+
default: 'bump'
18+
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
23+
jobs:
24+
release_process:
25+
name: Run the release process
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: true
31+
- name: Setup
32+
run: |
33+
rustc ci/publish.rs
34+
git config user.name 'Auto Release Process'
35+
git config user.email '[email protected]'
36+
git remote set-url origin https://git:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
37+
38+
- name: Bump version number
39+
run: ./publish ${{ github.event.inputs.action }}
40+
41+
- name: Prep PR metadata
42+
run: |
43+
set -ex
44+
git fetch origin
45+
46+
cur=$(./ci/print-current-version.sh)
47+
48+
git commit --allow-empty -a -F-<<EOF
49+
Release ${{ github.event.repository.name }} $cur
50+
51+
[automatically-tag-and-release-this-commit]
52+
EOF
53+
54+
# Push the result to a branch and setup metadata for the step below
55+
# that creates a PR
56+
git push origin HEAD:ci/release-$cur
57+
echo "PR_HEAD=ci/release-$cur" >> $GITHUB_ENV
58+
echo "PR_TITLE=Release ${{ github.event.repository.name }} $cur" >> $GITHUB_ENV
59+
echo "PR_BASE=main" >> $GITHUB_ENV
60+
cat > pr-body <<-EOF
61+
This is an automated pull request from CI to release
62+
${{ github.event.repository.name }} $cur when merged. The commit
63+
message for this PR has a marker that is detected by CI to create
64+
tags and publish crate artifacts.
65+
66+
When first opened this PR will not have CI run because it is generated
67+
by a bot. A maintainer should close this PR and then reopen it to
68+
trigger CI to execute which will then enable merging this PR.
69+
EOF
70+
71+
- name: Make a PR
72+
run: gh pr create -B "$PR_BASE" -H "$PR_HEAD" --title "$PR_TITLE" --body "$(cat ./pr-body)"
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ description = """
99
Tool for helping to find SSL certificate locations on the system for OpenSSL
1010
"""
1111
readme = "README.md"
12+
edition = '2021'
13+
14+
# This was arbitrarily chosen on 2025-01-23 as "pretty old" as previously
15+
# key didn't exist in `Cargo.toml` prior to that.
16+
rust-version = '1.60.0'

0 commit comments

Comments
 (0)