-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (104 loc) · 3.58 KB
/
CD.yml
File metadata and controls
109 lines (104 loc) · 3.58 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
name: CD
on:
release:
types: [released, prereleased]
workflow_dispatch:
permissions:
contents: read
jobs:
check-tag:
name: Check release tag
if: github.event_name == 'workflow_dispatch' || github.event_name == 'release'
runs-on: ubuntu-latest
outputs:
should-publish: ${{ github.event_name == 'workflow_dispatch' || steps.check.outputs.match == 'true' }}
should-release-zed: ${{ steps.check-zed.outputs.match == 'true' }}
crate-name: ${{ steps.check.outputs.crate-name }}
steps:
- name: Match crate semver tag
id: check
if: github.event_name == 'release'
run: |
TAG="${{ github.event.release.tag_name }}"
if [[ "$TAG" =~ ^(git-forge|forge-github|forge-mcp|forge-server)-v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
echo "match=true" >> "$GITHUB_OUTPUT"
echo "crate-name=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
else
echo "match=false" >> "$GITHUB_OUTPUT"
fi
- name: Match Zed extension tag
id: check-zed
if: github.event_name == 'release'
run: |
TAG="${{ github.event.release.tag_name }}"
if [[ "$TAG" =~ ^forge-zed-v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
echo "match=true" >> "$GITHUB_OUTPUT"
else
echo "match=false" >> "$GITHUB_OUTPUT"
fi
release:
name: Release
needs: check-tag
if: needs.check-tag.outputs.should-publish == 'true'
runs-on: ubuntu-latest
permissions:
# Used to sign the release artifacts
id-token: write
# Used to upload release artifacts
contents: write
# Used to generate artifact attestation
attestations: write
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: true
toolchain: stable
- name: Package crate
run: |
CRATE="${{ needs.check-tag.outputs.crate-name }}"
if [ -n "$CRATE" ]; then
cargo package -p "$CRATE"
else
cargo package --workspace
fi
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: "target/package/*.crate"
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
CRATE="${{ needs.check-tag.outputs.crate-name }}"
if [ -n "$CRATE" ]; then
PKG_FLAG="-p $CRATE"
else
PKG_FLAG="--workspace"
fi
cargo publish $PKG_FLAG --token "$CARGO_REGISTRY_TOKEN"
zed-extension:
name: Release Zed extension
needs: check-tag
if: needs.check-tag.outputs.should-release-zed == 'true'
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
attestations: write
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-wasip2
cache: true
- name: Build Zed extension
run: cargo build --manifest-path extensions/forge-zed/Cargo.toml --target wasm32-wasip2 --release
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: "extensions/forge-zed/target/wasm32-wasip2/release/forge_zed.wasm"
- name: Upload to GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ github.event.release.tag_name }}" extensions/forge-zed/target/wasm32-wasip2/release/forge_zed.wasm