|
| 1 | +image: ubuntu-latest |
| 2 | + |
| 3 | +steps: |
| 4 | + - name: Checkout repository |
| 5 | + uses: actions/checkout@v4 |
| 6 | + with: |
| 7 | + fetch-depth: 0 |
| 8 | + fetch-tags: true |
| 9 | + |
| 10 | + - name: Download artifacts |
| 11 | + uses: actions/download-artifact@v4 |
| 12 | + with: |
| 13 | + path: artifacts |
| 14 | + |
| 15 | + - run: |
| 16 | + name: Get version from Cargo.toml |
| 17 | + command: | |
| 18 | + VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') |
| 19 | + { |
| 20 | + echo "version=$VERSION" |
| 21 | + } >> "$GITHUB_OUTPUT" |
| 22 | +
|
| 23 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 24 | + TAG="${GITHUB_REF#refs/tags/}" |
| 25 | + EXPECTED_TAG="v$VERSION" |
| 26 | + if [ "$TAG" != "$EXPECTED_TAG" ]; then |
| 27 | + echo "Error: Tag $TAG doesn't match expected $EXPECTED_TAG from Cargo.toml" >&2 |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | + { |
| 31 | + echo "tag=$TAG" |
| 32 | + } >> "$GITHUB_OUTPUT" |
| 33 | + else |
| 34 | + { |
| 35 | + echo "tag=v$VERSION" |
| 36 | + } >> "$GITHUB_OUTPUT" |
| 37 | + fi |
| 38 | +
|
| 39 | + - run: |
| 40 | + name: Generate checksums |
| 41 | + command: | |
| 42 | + set -e |
| 43 | + cd artifacts |
| 44 | + for dir in */; do |
| 45 | + cd "$dir" |
| 46 | + for file in *; do |
| 47 | + case "$file" in |
| 48 | + *.tar.gz|*.zip) |
| 49 | + if [ -f "$file" ]; then |
| 50 | + sha256sum "$file" > "${file}.sha256" || shasum -a 256 "$file" | awk '{print $1}' > "${file}.sha256" |
| 51 | + fi |
| 52 | + ;; |
| 53 | + esac |
| 54 | + done |
| 55 | + cd .. |
| 56 | + done |
| 57 | + cd .. |
| 58 | +
|
| 59 | + - run: |
| 60 | + name: Generate changelog |
| 61 | + command: | |
| 62 | + cat > changelog.md <<EOF |
| 63 | + ## Installation |
| 64 | +
|
| 65 | + ### One-liner (Linux/macOS) |
| 66 | + curl -fsSL https://docspring.github.io/cigen/install.sh | sh |
| 67 | +
|
| 68 | + ### Direct downloads |
| 69 | + - macOS (Intel): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-macos-amd64.tar.gz |
| 70 | + - macOS (Apple Silicon): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-macos-arm64.tar.gz |
| 71 | + - Linux (x86_64): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-linux-amd64.tar.gz |
| 72 | + - Linux (ARM64): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-linux-arm64.tar.gz |
| 73 | + EOF |
| 74 | +
|
| 75 | + - name: Create GitHub Release |
| 76 | + uses: softprops/action-gh-release@v2 |
| 77 | + with: |
| 78 | + tag_name: ${{ steps.version.outputs.tag }} |
| 79 | + name: CIGen v${{ steps.version.outputs.version }} |
| 80 | + body_path: changelog.md |
| 81 | + draft: false |
| 82 | + prerelease: ${{ contains(steps.version.outputs.tag, '-') }} |
| 83 | + files: | |
| 84 | + artifacts/**/*.tar.gz |
| 85 | + artifacts/**/*.sha256 |
0 commit comments