-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (129 loc) · 4.59 KB
/
Copy pathrelease.yml
File metadata and controls
147 lines (129 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: release
on:
push:
tags:
- "v*"
workflow_dispatch: {}
permissions:
contents: write
jobs:
verify:
name: verify release metadata and packages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust 1.93
run: |
rustup toolchain install 1.93 --profile minimal
rustup default 1.93
- name: Verify synchronized release metadata
shell: bash
run: |
versions="$(
cargo metadata --format-version 1 --no-deps --locked \
| jq -r '.packages[] | select(.publish != []) | .version' \
| sort -u
)"
version_count="$(printf '%s\n' "${versions}" | sed '/^$/d' | wc -l)"
test "${version_count}" -eq 1
version="${versions}"
major="${version%%.*}"
grep -Fq "version = \"${version}\"" crates/sbol-py/Cargo.toml
grep -Fq "version = \"${version}\"" crates/sbol-py/pyproject.toml
grep -Fq "version: \"${version}\"" CITATION.cff
grep -Fq "## [${version}] - " CHANGELOG.md
grep -Fq "sbol = \"${major}\"" README.md
while IFS= read -r manifest; do
package_dir="$(dirname "${manifest}")"
cmp -s LICENSE-APACHE "${package_dir}/LICENSE-APACHE"
cmp -s LICENSE-MIT "${package_dir}/LICENSE-MIT"
cmp -s NOTICE "${package_dir}/NOTICE"
done < <(
cargo metadata --format-version 1 --no-deps --locked \
| jq -r '.packages[] | select(.publish != []) | .manifest_path'
)
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
test "${GITHUB_REF_NAME}" = "v${version}"
fi
- name: Verify publishable packages
run: cargo publish --dry-run --workspace --locked
build:
name: build ${{ matrix.target }}
needs: verify
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
- os: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust 1.93
run: |
rustup toolchain install 1.93 --profile minimal
rustup default 1.93
rustup target add ${{ matrix.target }}
- name: Build
run: cargo build --release --locked -p sbol-cli --target ${{ matrix.target }}
- name: Package (tar.gz)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
pkg="sbol-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir -p "dist/${pkg}"
cp "target/${{ matrix.target }}/release/sbol" "dist/${pkg}/"
cp README.md LICENSE-MIT LICENSE-APACHE NOTICE "dist/${pkg}/"
tar -C dist -czf "${pkg}.tar.gz" "${pkg}"
- name: Package (zip)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$pkg = "sbol-$env:GITHUB_REF_NAME-${{ matrix.target }}"
New-Item -ItemType Directory -Force -Path "dist/$pkg" | Out-Null
Copy-Item "target/${{ matrix.target }}/release/sbol.exe" "dist/$pkg/"
Copy-Item README.md, LICENSE-MIT, LICENSE-APACHE, NOTICE "dist/$pkg/"
Compress-Archive -Path "dist/$pkg" -DestinationPath "$pkg.zip"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: sbol-${{ matrix.target }}
path: |
*.tar.gz
*.zip
if-no-files-found: error
release:
name: publish release
needs: build
runs-on: ubuntu-latest
# Build artifacts on every trigger (including manual workflow_dispatch
# validation runs), but only publish a GitHub Release for tag pushes.
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish to GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
gh release create "${TAG}" dist/* \
--repo "${GITHUB_REPOSITORY}" \
--title "${TAG}" \
--generate-notes \
|| gh release upload "${TAG}" dist/* --repo "${GITHUB_REPOSITORY}" --clobber