Release #66
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: | |
workflow_run: | |
workflows: ["CI"] | |
types: | |
- completed | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
force: | |
description: 'Force a Release' | |
type: boolean | |
ref: | |
description: 'Commit SHA to run the workflow on' | |
required: true | |
default: 'main' | |
permissions: | |
contents: write | |
packages: read | |
actions: read | |
pull-requests: read | |
id-token: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
semrel: | |
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.inputs.force == 'true' }} | |
outputs: | |
current-version: ${{ steps.semrel.outputs.current-version }} | |
log: ${{ steps.semrel.outputs.log }} | |
next-version: ${{ steps.semrel.outputs.next-version }} | |
release-notes: ${{ steps.semrel.outputs.release-notes }} | |
version-changed: ${{ steps.semrel.outputs.version-changed }} | |
manifest-path: ${{ steps.semrel.outputs.manifest-path }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Build | |
run: cargo build | |
- name: Generate outputs | |
id: semrel | |
run: | | |
cp target/debug/semrel ./semrel | |
current_version=$(./semrel show current) | |
log=$(./semrel show log) | |
next_version=$(./semrel show next) | |
release_notes=$(./semrel show notes) | |
manifest_path=$(./semrel show manifest) | |
# Encode multiline outputs to base64 to handle special characters and newlines | |
encoded_release_notes=$(echo "$release_notes" | base64 | tr -d '\n') | |
encoded_log=$(echo "$log" | base64 | tr -d '\n') | |
echo "current-version=$current_version" >> $GITHUB_OUTPUT | |
echo "next-version=$next_version" >> $GITHUB_OUTPUT | |
echo "release-notes=$encoded_release_notes" >> $GITHUB_OUTPUT | |
echo "log=$encoded_log" >> $GITHUB_OUTPUT | |
echo "manifest-path=$manifest_path" >> $GITHUB_OUTPUT | |
if [ "$next_version" != "$current_version" ]; then | |
echo "version-changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "version-changed=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Debug Outputs | |
shell: bash | |
run: | | |
echo "version-changed: ${{ steps.semrel.outputs.version-changed }}" | |
echo "current-version: ${{ steps.semrel.outputs.current-version }}" | |
echo "next-version: ${{ steps.semrel.outputs.next-version }}" | |
echo "manifest-path: ${{ steps.semrel.outputs.manifest-path }}" | |
./semrel show log | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: debug | |
path: target/debug/semrel | |
commit: | |
needs: [semrel] | |
if: ${{ needs.semrel.outputs.version-changed == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v4 | |
- name: Set permissions on artifacts | |
run: | | |
cp debug/semrel ./semrel | |
chmod +x ./semrel | |
- name: Bump manifest version | |
run: ./semrel update | |
- name: Update lock | |
run: cargo update | |
- name: Setup git | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
- name: Stage files | |
run: git add Cargo.toml Cargo.lock | |
- name: Create commit | |
run: printf "%s" "$(./semrel show release-commit)" | git commit -F - | |
- name: Push commit | |
run: git push origin HEAD:main | |
native-build: | |
needs: [semrel, commit] | |
if: ${{ needs.semrel.outputs.version-changed == 'true' }} | |
strategy: | |
matrix: | |
include: | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Build | |
run: cargo build --release --target=${{ matrix.target }} | |
- name: Archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/semrel | |
cross-build: | |
needs: [semrel, commit] | |
if: ${{ needs.semrel.outputs.version-changed == 'true' }} | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Cache Cross | |
id: cache-cross | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/bin/cross | |
key: ${{ matrix.os }}-cross | |
- name: Install Cross | |
run: | | |
if command -v cross &> /dev/null | |
then | |
echo "Cross is installed."; | |
else | |
echo "Cross must be installed."; | |
cargo install cross | |
fi | |
- name: Cross Build | |
run: | | |
cross build --target ${{ matrix.target }} --release | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/semrel | |
release: | |
needs: [cross-build, native-build, semrel] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
- name: Set permissions on artifacts | |
run: | | |
chmod +x aarch64-apple-darwin/semrel | |
chmod +x x86_64-apple-darwin/semrel | |
chmod +x aarch64-unknown-linux-musl/semrel | |
chmod +x x86_64-unknown-linux-musl/semrel | |
cp x86_64-unknown-linux-musl/semrel ./semrel | |
- name: Create Release Notes | |
run: ./semrel show notes > release-notes-$(./semrel show next).md | |
- name: Update artifact names | |
run: | | |
mv aarch64-apple-darwin/semrel aarch64-apple-darwin/semrel-${{ needs.semrel.outputs.next-version }}-amd64-apple-darwin | |
mv x86_64-apple-darwin/semrel x86_64-apple-darwin/semrel-${{ needs.semrel.outputs.next-version }}-x86_64-apple-darwin | |
mv aarch64-unknown-linux-musl/semrel aarch64-unknown-linux-musl/semrel-${{ needs.semrel.outputs.next-version }}-aarch64-unknown-linux-musl | |
mv x86_64-unknown-linux-musl/semrel x86_64-unknown-linux-musl/semrel-${{ needs.semrel.outputs.next-version }}-x86_64-unknown-linux-musl | |
cp x86_64-unknown-linux-musl/semrel-${{ needs.semrel.outputs.next-version }}-x86_64-unknown-linux-musl ~/.cargo/bin/semrel | |
- name: Install tar | |
run: sudo apt-get install tar | |
- name: Package Artifacts | |
run: | | |
tar czvf semrel-${{ needs.semrel.outputs.next-version }}-arm64-apple-darwin.tgz -C aarch64-apple-darwin . | |
tar czvf semrel-${{ needs.semrel.outputs.next-version }}-x86_64-apple-darwin.tgz -C x86_64-apple-darwin . | |
tar czvf semrel-${{ needs.semrel.outputs.next-version }}-aarch64-unknown-linux-musl.tgz -C aarch64-unknown-linux-musl . | |
tar czvf semrel-${{ needs.semrel.outputs.next-version }}-x86_64-unknown-linux-musl.tgz -C x86_64-unknown-linux-musl . | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
semrel-${{ needs.semrel.outputs.next-version }}-arm64-apple-darwin.tgz | |
semrel-${{ needs.semrel.outputs.next-version }}-x86_64-apple-darwin.tgz | |
semrel-${{ needs.semrel.outputs.next-version }}-aarch64-unknown-linux-musl.tgz | |
semrel-${{ needs.semrel.outputs.next-version }}-x86_64-unknown-linux-musl.tgz | |
name: semrel-${{ needs.semrel.outputs.next-version }} | |
body_path: release-notes-${{ needs.semrel.outputs.next-version }}.md | |
generate_release_notes: false | |
make_latest: true | |
draft: false | |
prerelease: false | |
tag_name: ${{ needs.semrel.outputs.next-version }} | |
token: ${{ secrets.GITHUB_TOKEN }} |