Skip to content

Merge pull request #33 from chenrui333/update-actions #29

Merge pull request #33 from chenrui333/update-actions

Merge pull request #33 from chenrui333/update-actions #29

Workflow file for this run

name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
permissions: write-all
jobs:
# Creates a release and outputs the url
create-release:
name: create-release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
version: ${{ env.VERSION }}
steps:
- name: Get the release version from the tag
shell: bash
if: env.VERSION == ''
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.VERSION }}"
- name: Create GitHub release
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.VERSION,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.VERSION,
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
build-and-upload:
name: Build and upload
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos]
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
- build: macos
os: macos-latest
target: x86_64-apple-darwin
use-cross: true
- build: windows-gnu
os: windows-latest
target: x86_64-pc-windows-gnu
use-cross: false
- build: windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
use-cross: false
- build: windows32-msvc
os: windows-latest
target: i686-pc-windows-msvc
use-cross: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1
with:
target: ${{ matrix.target }}
- name: Install Cross
if: matrix.use-cross == 'true'
run: cargo install cross
- name: Build
run: |
if [ "${{ matrix.use-cross }}" = "true" ]; then
# Ensure cross is installed above if not included in your toolchain
cross build --verbose --release --target ${{ matrix.target }}
else
cargo build --verbose --release --target ${{ matrix.target }}
fi
- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/prj"
- name: Build archive
shell: bash
run: |
dirname="projectable-${{ needs.create-release.outputs.version }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/prj.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/prj" "$dirname"
fi
mv LICENSE "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Upload archive
uses: actions/upload-release-asset@64e5e85fc528f162d7ba7ce2d15a3bb67efb3d80 # v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
publish-cargo:
name: Publish to Cargo
runs-on: ubuntu-latest
steps:

Check failure on line 140 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

You have an error in your yaml syntax on line 140
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1
- name: Publish to Cargo
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_KEY }}