-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (77 loc) · 3.05 KB
/
prerelease-rust-sdk.yml
File metadata and controls
90 lines (77 loc) · 3.05 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
name: WIP Release Rust SDK
permissions:
contents: read
on:
workflow_dispatch:
inputs:
tag:
description: 'Pre-release label (e.g. alpha, beta, rc)'
required: true
default: 'beta'
branch:
description: 'Branch containing the WIP changes'
required: true
default: 'main'
env:
CARGO_TERM_COLOR: always
jobs:
wip-release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/rust/iii
steps:
- name: Warning
working-directory: .
run: |
echo "WARNING: WIP Release bypasses the approval gate"
echo "This workflow should only be used for testing purposes"
echo "For production releases, use the Create Tag workflow instead"
echo ""
echo "Publishing pre-release with label: ${{ github.event.inputs.tag }}"
echo "From branch: ${{ github.event.inputs.branch }}"
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry & build
uses: Swatinem/rust-cache@v2
with:
workspaces: packages/rust/iii
- name: Get current version
id: current_version
run: |
CURRENT=$(grep '^version = ' Cargo.toml | head -n1 | cut -d'"' -f2)
echo "Current version: $CURRENT"
echo "version=$CURRENT" >> $GITHUB_OUTPUT
- name: Set pre-release version
id: version
run: |
TAG="${{ github.event.inputs.tag }}"
CURRENT="${{ steps.current_version.outputs.version }}"
BASE_VERSION=$(echo "$CURRENT" | cut -d'-' -f1)
TIMESTAMP=$(date +%Y%m%d%H%M%S)
NEW_VERSION="${BASE_VERSION}-${TAG}.${TIMESTAMP}"
sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" Cargo.toml
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Show version information
working-directory: .
run: |
echo "### Version Information" >> $GITHUB_STEP_SUMMARY
echo "- **Package:** iii-sdk" >> $GITHUB_STEP_SUMMARY
echo "- **Current version:** ${{ steps.current_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **New version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Pre-release label:** ${{ github.event.inputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.event.inputs.branch }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "cargo add iii-sdk@${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Publish to crates.io
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}