Skip to content

fix(actions): repeat id #241

fix(actions): repeat id

fix(actions): repeat id #241

Workflow file for this run

name: release
on:
# schedule:
# - cron: "5 5 * * *"
workflow_dispatch:
# inputs:
# tag_name:
# description: "Tag name for release"
# required: false
# default: nightly
push:
tags:
- "v*.*.*"
- "*.*.*"
env:
CARGO_TERM_COLOR: always
USE_CROSS: true
FETCH_DEPTH: 0
RELEASE_NAME: "stow-cm"
defaults:
run:
shell: bash
jobs:
build:
runs-on: ${{ matrix.build.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
# build: [linux, linux-arm, macos, win-msvc, win-gnu, win32-msvc]
build: [
{
plat: linux,
os: ubuntu-latest,
rust: stable,
target: x86_64-unknown-linux-musl,
},
{
plat: macos,
os: macos-latest,
rust: stable,
target: x86_64-apple-darwin,
},
# {
# plat: linux-arm,
# os: ubuntu-latest,
# rust: stable,
# target: arm-unknown-linux-gnueabihf
# },
# {
# plat: win-msvc,
# os: windows-latest,
# rust: stable,
# target: x86_64-pc-windows-msvc
# },
# {
# plat: win-gnu,
# os: windows-latest,
# rust: stable-x86_64-gnu,
# target: x86_64-pc-windows-gnu
# },
# {
# plat: win32-msvc,
# os: windows-latest,
# rust: stable,
# target: i686-pc-windows-msvc
# },
]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.build.rust }}
targets: ${{ matrix.build.target }}
- uses: Swatinem/rust-cache@v2
- name: build release binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target=${{ matrix.build.target }}
use-cross: ${{ env.USE_CROSS }}
- name: Strip release binary (linux and macos)
if: matrix.build.plat == 'linux' || matrix.build.plat == 'macos'
run: strip "target/${{ matrix.build.target }}/release/${{ env.RELEASE_NAME }}"
- name: Strip release binary (arm)
if: matrix.build.plat == 'linux-arm'
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
rustembedded/cross:arm-unknown-linux-gnueabihf \
arm-linux-gnueabihf-strip \
/target/arm-unknown-linux-gnueabihf/release/${{ env.RELEASE_NAME }}
- name: Build archive
shell: bash
run: |
staging="${{ env.RELEASE_NAME }}-${{ matrix.build.target }}"
mkdir -p "$staging"
mkdir -p "artifacts"
cp {README.md,LICENSE} "$staging/"
if [ "${{ matrix.build.os }}" = "windows-latest" ]; then
cp "target/${{ matrix.build.target }}/release/${{ env.RELEASE_NAME }}.exe" "$staging/"
7z a "artifacts/$staging.zip" "$staging"
sha256sum "artifacts/$staging.zip" > "artifacts/$staging.zip.sha256sum"
else
cp "target/${{ matrix.build.target }}/release/${{ env.RELEASE_NAME }}" "$staging/"
tar czf "artifacts/$staging.tar.gz" "$staging"
shasum -a 256 "artifacts/$staging.tar.gz" > "artifacts/$staging.tar.gz.sha256sum"
fi
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.build.target }}
path: artifacts/*
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: delete exist release
run: gh release delete stable --cleanup-tag
continue-on-error: true
env:
GITHUB_TOKEN: ${{ github.token }}
# uses: actions/github-script@v7
# with:
# script: |
# let tagName = "stable"
# try {
# const { data: { id:release_id } } = await github.rest.repos.getReleaseByTag({
# owner: context.repo.owner,
# repo: context.repo.repo,
# tag: tagName,
# });
# if ( release_id ) {
# await github.rest.repos.deleteRelease({
# owner: context.repo.owner,
# repo: context.repo.repo,
# release_id,
# });
# }
# await github.rest.git.deleteRef({
# owner: context.repo.owner,
# repo: context.repo.repo,
# ref: `tags/${tagName}`,
# });
# } catch (e) {
# console.error(e)
# }
- name: download assets
uses: actions/download-artifact@v4
with:
path: artifact
merge-multiple: true
- name: "build Changelog"
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
token: "${{ github.token }}"
# mode: "HYBRID"
mode: "COMMIT"
- name: create tag release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
append_body: true
body: ${{steps.build_changelog.outputs.changelog}}
tag_name: "${{ github.ref_name }}"
name: "Release ${{ github.ref_name }}"
target_commitish: "${{ github.sha }}"
prerelease: false
draft: false
fail_on_unmatched_files: false
files: |
artifacts/*
- name: create stable release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
append_body: true
body: ${{steps.build_changelog.outputs.changelog}}
tag_name: "stable"
name: "Release stable"
target_commitish: "${{ github.sha }}"
prerelease: false
draft: false
make_latest: false
fail_on_unmatched_files: false
files: |
artifacts/*