Bump version to 0.4.2. #9
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: | |
- "v*" | |
workflow_dispatch: | |
inputs: | |
tags: | |
description: The tags to be released | |
required: false | |
type: string | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
create_release: | |
name: create release | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.generated-tag.outputs.tag }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get latest tag | |
id: get-latest-tag | |
run: | | |
echo "tag=`gh release list -L 1 | cut -f 1`" >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Bump version | |
id: generated-tag | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
if (context.ref.startsWith("refs/tags/")) { | |
let tag = context.ref.replace("refs/tags/", ""); | |
core.setOutput('tag', tag); | |
console.log(`This event pushed a tag ${tag}, return directly.`) | |
return | |
} | |
if ("${{ github.event.inputs.tags }}") { | |
let tag = "${{ github.event.inputs.tags }}"; | |
core.setOutput('tag', tag); | |
console.log(`This event triggered by workflow_dispatch with a tag ${tag}, return directly.`) | |
return | |
} | |
let tag = "${{ steps.get-latest-tag.outputs.tag }}"; | |
let result = /v(\d+)\.(\d+)\.(\d+)/g.exec(tag); | |
if (result === null) { | |
throw `The previous tag ${{ steps.get-latest-tag.outputs.tag }} is invalid, ignoring`; | |
} | |
let major = result[1]; | |
let minor = result[2]; | |
let patch = (parseInt(result[3]) + 1).toString(); | |
let next_tag = `v${major}.${minor}.${patch}-nightly`; | |
console.log(`This event is triggered, return generated ${next_tag}.`) | |
core.setOutput('tag', next_tag) | |
- name: Create github release if not exist | |
# Allow this action failure | |
continue-on-error: true | |
# Reference: https://cli.github.com/manual/gh_release_create | |
run: | | |
echo "Create a release for ${{ steps.generated-tag.outputs.tag }}" | |
gh release create ${{ steps.generated-tag.outputs.tag }} --generate-notes -p | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish_macos: | |
name: macos assets | |
runs-on: macos-11 | |
needs: [create_release] | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- x86_64 | |
- aarch64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get target | |
id: target | |
run: echo 'target=${{ matrix.arch }}-apple-darwin' >> $GITHUB_OUTPUT | |
- name: Rust setup | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
components: clippy | |
override: true | |
- name: Install coreutils for macOS sha256sum | |
run: brew install coreutils | |
- name: Cross setup | |
if: matrix.arch == 'aarch64' | |
run: | | |
rustup target add aarch64-apple-darwin | |
- name: Build Binary | |
run: | | |
target=${{ steps.target.outputs.target }} | |
version=${{ needs.create_release.outputs.version }} | |
cargo build --release --target=${target} | |
cp ./target/${target}/release/blooming blooming-${version}-${target} | |
- name: generate sha256sums | |
run: | | |
target=${{ steps.target.outputs.target }} | |
version=${{ needs.create_release.outputs.version }} | |
sha256sum blooming-${version}-${target} >> sha256-${version}-${target}.txt | |
- name: post sha256 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: sha256sums | |
path: sha256-${{ needs.create_release.outputs.version }}-${{ steps.target.outputs.target }}.txt | |
retention-days: 1 | |
- name: Publish Binaries | |
uses: ./.github/actions/publish_binary | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
version: ${{ needs.create_release.outputs.version }} | |
target: ${{ steps.target.outputs.target }} | |
publish_linux: | |
name: linux assets | |
runs-on: ubuntu-latest | |
needs: [create_release] | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- x86_64 | |
platform: | |
- gnu | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get the version | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT | |
- name: Get target | |
id: target | |
run: echo 'target=${{ matrix.arch }}-unknown-linux-${{ matrix.platform }}' >> $GITHUB_OUTPUT | |
- name: Rust setup | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
components: clippy | |
override: true | |
- name: Build Binary | |
run: | | |
target=${{ steps.target.outputs.target }} | |
version=${{ needs.create_release.outputs.version }} | |
cargo build --release --target=${target} | |
cp ./target/${target}/release/blooming blooming-${version}-${target} | |
- name: generate sha256sums | |
run: | | |
target=${{ steps.target.outputs.target }} | |
version=${{ needs.create_release.outputs.version }} | |
sha256sum blooming-${version}-${target} >> sha256-${version}-${target}.txt | |
- name: post sha256 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: sha256sums | |
path: sha256-${{ needs.create_release.outputs.version }}-${{ steps.target.outputs.target }}.txt | |
retention-days: 1 | |
- name: Publish Binaries | |
uses: ./.github/actions/publish_binary | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
version: ${{ needs.create_release.outputs.version }} | |
target: ${{ steps.target.outputs.target }} | |
upload-sha256sums-plugin: | |
needs: [create_release, publish_linux, publish_macos] | |
runs-on: ubuntu-latest | |
name: upload-sha256sums | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: Get Pre-release | |
uses: cardinalby/git-get-release-action@v1 | |
id: latest_pre_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
prerelease: true | |
latest: true | |
- name: download sha256sums | |
uses: actions/download-artifact@v2 | |
with: | |
name: sha256sums | |
- shell: bash | |
run: | | |
for file in *.txt | |
do | |
cat ${file} >> sha256sums.txt | |
done | |
- name: upload checksums | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.latest_pre_release.outputs.upload_url }} | |
asset_path: sha256sums.txt | |
asset_name: sha256sums.txt | |
asset_content_type: text/plain |