-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (126 loc) · 5.37 KB
/
release.yml
File metadata and controls
147 lines (126 loc) · 5.37 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:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
default: 'patch'
pre_release:
description: 'Mark as pre-release'
required: false
type: boolean
default: false
jobs:
release:
runs-on: ubuntu-22.04
# Only run on master branch
if: github.ref == 'refs/heads/master'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# PAT with repo scope needed to push to protected master branch.
# GITHUB_TOKEN cannot bypass branch protection rules.
token: ${{ secrets.RELEASE_PAT }}
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: '1.91.0'
components: 'clippy, rustfmt'
- name: Install cargo-edit for version bumping
run: cargo install cargo-edit --version 0.12.3 --locked
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get current version
id: current_version
run: |
CURRENT_VERSION=$(grep -m 1 '^version = ' datafusion/bio-function-pileup/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
- name: Bump version in all crates
id: bump_version
run: |
# Bump version once - cargo set-version updates all workspace members
echo "Bumping version for all workspace members"
cargo set-version --manifest-path datafusion/bio-function-pileup/Cargo.toml --bump ${{ inputs.version_type }}
# Get the new version
NEW_VERSION=$(grep -m 1 '^version = ' datafusion/bio-function-pileup/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
- name: Update Cargo.lock
run: cargo check --all
- name: Run tests
run: cargo test --all
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build documentation
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: "-D warnings"
- name: Commit version bump
run: |
git add -A
git commit -m "chore: release v${{ steps.bump_version.outputs.version }}"
- name: Create and push tag
run: |
git tag -a "v${{ steps.bump_version.outputs.version }}" -m "Release v${{ steps.bump_version.outputs.version }}"
git push origin master
git push origin "v${{ steps.bump_version.outputs.version }}"
- name: Generate changelog
id: changelog
run: |
# Get the previous tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "First release - no previous tag found"
CHANGELOG="First release of datafusion-bio-functions"
else
echo "Generating changelog from $PREV_TAG to v${{ steps.bump_version.outputs.version }}"
CHANGELOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi
# Save changelog to file
echo "$CHANGELOG" > /tmp/changelog.md
echo "## What's Changed" >> /tmp/release_notes.md
echo "" >> /tmp/release_notes.md
echo "$CHANGELOG" >> /tmp/release_notes.md
echo "" >> /tmp/release_notes.md
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...v${{ steps.bump_version.outputs.version }}" >> /tmp/release_notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.bump_version.outputs.version }}
name: Release v${{ steps.bump_version.outputs.version }}
body_path: /tmp/release_notes.md
draft: false
prerelease: ${{ inputs.pre_release }}
generate_release_notes: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Optional: Publish to crates.io (uncomment when ready)
# - name: Publish to crates.io
# run: |
# cargo publish --manifest-path datafusion/bio-function-pileup/Cargo.toml --token ${{ secrets.CARGO_TOKEN }}
# env:
# CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Summary
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Previous Version**: ${{ steps.current_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **New Version**: ${{ steps.bump_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Version Bump**: ${{ inputs.version_type }}" >> $GITHUB_STEP_SUMMARY
echo "- **Pre-release**: ${{ inputs.pre_release }}" >> $GITHUB_STEP_SUMMARY
echo "- **Tag**: v${{ steps.bump_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Release created successfully!" >> $GITHUB_STEP_SUMMARY