Skip to content

Commit

Permalink
Fix release version in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Jul 13, 2024
1 parent 8a3c0dd commit aeea031
Showing 1 changed file with 58 additions and 55 deletions.
113 changes: 58 additions & 55 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,34 @@ name: Build Executables
on:
push:
tags:
- '*'
- 'v*'

jobs:
permissions:
contents: write

release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
# Create release when pushing a tag.
if: startsWith(github.ref, 'refs/tags/')
with:
name: Release ${{ github.ref }}
tag_name: ${{ github.ref }}
# TODO: proper release content, now it's manually updated.
body: Release ${{ steps.get_version.outputs.VERSION }}
draft: true
prerelease: true
jobs:
# release:
# name: Create Release
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

# - name: Get version
# id: get_version
# run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

# - name: Create Release
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ github.ref }}
# release_name: Release ${{ github.ref }}
# body: Release ${{ steps.get_version.outputs.VERSION }}
# draft: true
# prerelease: true

publish:
name: Build ${{ matrix.build.target }} on ${{ matrix.build.os }}
Expand Down Expand Up @@ -91,36 +90,40 @@ jobs:
version: "15.0"
if: ${{ matrix.build.os == 'macos-latest' || matrix.build.os == 'macos-14' }}

- name: Install target
run: |
rustup target add ${{ matrix.build.target }}
- name: Install cross
run: |
cargo install cross --git https://github.com/cross-rs/cross
if: ${{ matrix.build.command == 'cross' }}

- name: Configure cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.build.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build binary
run: |
${{ matrix.build.command }} build --profile production --bin subcoin --locked --target ${{ matrix.build.target }}
# - name: Install target
# run: |
# rustup target add ${{ matrix.build.target }}

# - name: Install cross
# run: |
# cargo install cross --git https://github.com/cross-rs/cross
# if: ${{ matrix.build.command == 'cross' }}

# - name: Configure cache
# uses: actions/cache@v4
# with:
# path: |
# ~/.cargo/bin/
# ~/.cargo/registry/index/
# ~/.cargo/registry/cache/
# ~/.cargo/git/db/
# target/
# key: ${{ runner.os }}-${{ matrix.build.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# - name: Build binary
# run: |
# ${{ matrix.build.command }} build --profile production --bin subcoin --locked --target ${{ matrix.build.target }}

- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
if: startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.build.target }}/production/${{ matrix.build.artifact_name }}
asset_name: subcoin-${{ github.ref }}-${{ matrix.build.os_prefix }}-${{ matrix.build.target }}
# file: target/${{ matrix.build.target }}/production/${{ matrix.build.artifact_name }}
file: README.md
asset_name: ${{ matrix.build.artifact_name }}-${{ matrix.build.target }}
tag: ${{ github.ref }}
overwrite: true
prerelease: true

0 comments on commit aeea031

Please sign in to comment.