fix: upload URL #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- "*" | |
jobs: | |
build: | |
name: Build and Release for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
asset_name: gitlab-ls_linux.tar.gz | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
asset_name: gitlab-ls_mac.tar.gz | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
asset_name: gitlab-ls_windows.zip | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Build release | |
run: cargo build --release --target ${{ matrix.target }} | |
env: | |
CARGO_INCREMENTAL: 0 | |
- name: Package the executable | |
run: | | |
mkdir output | |
cp target/${{ matrix.target }}/release/gitlab-ls* output/ | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
7z a ${{ matrix.asset_name }} ./output/* | |
else | |
tar czvf ${{ matrix.asset_name }} -C output . | |
fi | |
shell: bash | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.asset_name }} | |
path: ${{ matrix.asset_name }} | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: success() | |
steps: | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts/ | |
- name: Upload Release Assets | |
run: | | |
for file in artifacts/*; do | |
echo "Uploading $file" | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Content-Type: application/octet-stream" \ | |
"${{ steps.create_release.outputs.upload_url }}$(basename "$file")" \ | |
--data-binary "@$file" | |
done | |
shell: bash |