Repository navigation
185 lines (163 loc) · 5.77 KB
/
Copy pathrelease-assets.yml
File metadata and controls
185 lines (163 loc) · 5.77 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Release Assets
run-name: Release Assets (${{ inputs.tag }})
on:
workflow_dispatch:
inputs:
tag:
description: "Existing release tag to build and upload assets for"
required: true
type: string
source_run_id:
description: "Optional parent release workflow run id"
required: false
type: string
source_run_url:
description: "Optional parent release workflow run URL"
required: false
type: string
permissions:
contents: write
packages: write
id-token: write
env:
CARGO_TERM_COLOR: always
jobs:
build-release-assets:
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
asset_target: unknown-linux-gnu-aarch64
binary_name: dotenv
install_cmd: ""
linker: ""
- name: Linux x86_64
runner: ubuntu-24.04
target: x86_64-unknown-linux-gnu
asset_target: unknown-linux-gnu-x86_64
binary_name: dotenv
install_cmd: ""
linker: ""
- name: RHEL arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
asset_target: unknown-linux-musl-aarch64
binary_name: dotenv
install_cmd: sudo apt-get update && sudo apt-get install -y musl-tools
linker: musl-gcc
- name: RHEL x86_64
runner: ubuntu-24.04
target: x86_64-unknown-linux-musl
asset_target: unknown-linux-musl-x86_64
binary_name: dotenv
install_cmd: sudo apt-get update && sudo apt-get install -y musl-tools
linker: musl-gcc
- name: Windows x86_64
runner: ubuntu-24.04
target: x86_64-pc-windows-gnu
asset_target: pc-windows-gnu-x86_64
binary_name: dotenv.exe
install_cmd: sudo apt-get update && sudo apt-get install -y mingw-w64
linker: ""
steps:
- name: Resolve release tag
id: meta
shell: bash
run: |
set -euo pipefail
if [ -n "${{ inputs.tag || '' }}" ]; then
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "No release tag was provided." >&2
exit 1
fi
- name: Check out tagged source
uses: actions/checkout@v7
with:
ref: ${{ steps.meta.outputs.tag }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install target-specific build tooling
if: matrix.install_cmd != ''
shell: bash
run: ${{ matrix.install_cmd }}
- name: Run tests
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: cargo test --locked --all-features
- name: Build release binary
shell: bash
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.target == 'aarch64-unknown-linux-musl' && matrix.linker || '' }}
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.target == 'x86_64-unknown-linux-musl' && matrix.linker || '' }}
run: cargo build --locked --release --target ${{ matrix.target }}
- name: Compress release binary
shell: bash
run: |
set -euo pipefail
asset="dotenv-cli-${{ steps.meta.outputs.tag }}-${{ matrix.asset_target }}.gz"
gzip -n -c "target/${{ matrix.target }}/release/${{ matrix.binary_name }}" > "$asset"
echo "ASSET_PATH=$asset" >> "$GITHUB_ENV"
- name: Upload asset to GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ steps.meta.outputs.tag }}" "$ASSET_PATH" --clobber
- name: Add run summary
shell: bash
run: |
{
echo "## Release Assets"
echo
echo "- Tag: \`${{ steps.meta.outputs.tag }}\`"
echo "- Target: \`${{ matrix.target }}\`"
if [[ -n "${{ inputs.source_run_url }}" ]]; then
echo "- Triggered by: ${{ inputs.source_run_url }}"
fi
} >> "$GITHUB_STEP_SUMMARY"
publish-release:
name: Publish release
needs: build-release-assets
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v7
with:
ref: ${{ inputs.tag }}
- name: Publish release and trigger Homebrew tap update
id: publish
env:
GH_TOKEN: ${{ github.token }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
shell: bash
run: bash devops/publish-if-complete.sh "${{ inputs.tag }}"
- name: Set up Node for npm
if: steps.publish.outputs.published == 'true'
uses: actions/setup-node@v7
with:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Install package dependencies
if: steps.publish.outputs.published == 'true'
run: npm ci --ignore-scripts
- name: Publish to npm
if: steps.publish.outputs.published == 'true'
run: npm publish --access public
- name: Set up Node for GitHub Packages
if: steps.publish.outputs.published == 'true'
uses: actions/setup-node@v7
with:
node-version: 24
registry-url: https://npm.pkg.github.com
package-manager-cache: false
- name: Publish to GitHub Packages
if: steps.publish.outputs.published == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}