-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
115 lines (103 loc) · 3.59 KB
/
action.yml
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
name: 'Reloaded Publish Action'
description: 'Publish artifacts from other GitHub Actions'
author: 'Reloaded Project'
branding:
icon: 'package'
color: 'red'
inputs:
nuget-api-key:
description: 'NuGet API key for publishing packages'
required: false
crates-io-token:
description: 'Crates.io token for publishing Rust packages'
required: false
rust-project-paths:
description: 'List of paths to Rust projects'
required: false
default: '.'
artifacts-directory:
description: 'Path to the directory containing the uncompressed artifacts'
required: false
default: 'artifacts'
compressed-artifacts-directory:
description: 'Path to the directory containing the compressed artifacts'
required: false
default: 'compressed-artifacts'
additional-publish-params:
description: 'Additional parameters for cargo publish (e.g., --dry-run)'
required: false
default: ''
create-release:
description: 'Whether the artifacts should by uploaded to GitHub releases.'
required: false
default: 'true'
checkout-current-repo:
description: 'Checks out the current repository.'
required: false
default: 'true'
runs:
using: 'composite'
steps:
- name: Checkout repository
if: inputs.checkout-current-repo == 'true'
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ inputs.artifacts-directory }}
- name: Upload to NuGet
if: inputs.nuget-api-key != ''
shell: pwsh
run: |
$items = Get-ChildItem -Path "${{ inputs.artifacts-directory }}/**.nupkg" -Recurse
Foreach ($item in $items)
{
Write-Host "Pushing $item"
dotnet nuget push "$item" -k "${{ inputs.nuget-api-key }}" -s "https://api.nuget.org/v3/index.json" --skip-duplicate
}
$items = Get-ChildItem -Path "${{ inputs.artifacts-directory }}/**.snupkg" -Recurse
Foreach ($item in $items)
{
Write-Host "Pushing Symbol Package $item"
dotnet nuget push "$item" -k "${{ inputs.nuget-api-key }}" -s "https://api.nuget.org/v3/index.json" --skip-duplicate
}
- name: Compress artifacts
shell: bash
run: |
dir="${{ inputs.artifacts-directory }}"
compressed_dir="${{ inputs.compressed-artifacts-directory }}"
mkdir -p "$compressed_dir"
if [ ! -d "$dir" ]; then
echo "Directory $dir does not exist. No artifacts found."
exit 0
fi
for subdir in "$dir"/*; do
if [ -d "$subdir" ]; then
base=$(basename "$subdir")
zip -r "$compressed_dir/$base.zip" "$subdir"
fi
done
ls -A ./$compressed_dir
- name: Create GitHub release
if: inputs.create-release == 'true'
uses: softprops/action-gh-release@v2
with:
files: |
${{ inputs.compressed-artifacts-directory }}/*
- name: Publish to crates.io
if: inputs.crates-io-token != ''
shell: bash
run: |
# Trim whitespace and handle empty lines
echo "${{ inputs.rust-project-paths }}" | while read -r path || [[ -n "$path" ]]; do
# Skip empty lines
if [[ -z "$path" ]]; then
continue
fi
# Trim whitespace
path=$(echo "$path" | xargs)
echo "Publishing Rust package at path: $path"
cargo publish --token "${{ inputs.crates-io-token }}" ${{ inputs.additional-publish-params }} --manifest-path "$path/Cargo.toml"
done