-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (152 loc) · 5.07 KB
/
release.yml
File metadata and controls
155 lines (152 loc) · 5.07 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
148
149
150
151
152
153
154
155
name: release
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
release_build:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Wait for required checks
uses: actions/github-script@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cross (for cross-compilation)
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build binary
run: |
set -e
if [ "${{ matrix.use-cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }} --bin cigen
else
cargo build --release --target ${{ matrix.target }} --bin cigen
fi
- name: Create archive
run: |
set -e
cd "target/${{ matrix.target }}/release"
tar czf "../../../${{ matrix.name }}.tar.gz" cigen
cd ../../../
echo "ASSET_PATH=${{ matrix.name }}.tar.gz" >> "$GITHUB_ENV"
- name: Upload artifact
uses: actions/upload-artifact@v4
strategy:
matrix:
include:
- name: cigen-macos-amd64
os: macos-latest
target: x86_64-apple-darwin
- name: cigen-macos-arm64
os: macos-latest
target: aarch64-apple-darwin
- name: cigen-linux-amd64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: cigen-linux-arm64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use-cross: true
fail-fast: false
docker_image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version
run: |
VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
- name: Build and push multi-arch image
run: |
set -euo pipefail
VERSION="${{ steps.v.outputs.version }}"
echo "Building docspringcom/cigen:${VERSION} and :latest"
docker buildx build \
--platform linux/amd64,linux/arm64 \
-f Dockerfile \
--build-arg CIGEN_VERSION="${VERSION}" \
-t docspringcom/cigen:"${VERSION}" \
-t docspringcom/cigen:latest \
--push .
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
permissions:
contents: read
release_create:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Get version from Cargo.toml
run: |
VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
{
echo "version=$VERSION"
} >> "$GITHUB_OUTPUT"
if [ "${{ github.event_name }}" = "push" ]; then
TAG="${GITHUB_REF#refs/tags/}"
EXPECTED_TAG="v$VERSION"
if [ "$TAG" != "$EXPECTED_TAG" ]; then
echo "Error: Tag $TAG doesn't match expected $EXPECTED_TAG from Cargo.toml" >&2
exit 1
fi
{
echo "tag=$TAG"
} >> "$GITHUB_OUTPUT"
else
{
echo "tag=v$VERSION"
} >> "$GITHUB_OUTPUT"
fi
- name: Generate checksums
run: |
set -e
cd artifacts
for dir in */; do
cd "$dir"
for file in *; do
case "$file" in
*.tar.gz|*.zip)
if [ -f "$file" ]; then
sha256sum "$file" > "${file}.sha256" || shasum -a 256 "$file" | awk '{print $1}' > "${file}.sha256"
fi
;;
esac
done
cd ..
done
cd ..
- name: Generate changelog
run: |
cat > changelog.md <<EOF
## Installation
### One-liner (Linux/macOS)
curl -fsSL https://docspring.github.io/cigen/install.sh | sh
### Direct downloads
- macOS (Intel): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-macos-amd64.tar.gz
- macOS (Apple Silicon): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-macos-arm64.tar.gz
- Linux (x86_64): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-linux-amd64.tar.gz
- Linux (ARM64): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-linux-arm64.tar.gz
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v2