Skip to content

Release

Release #151

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
increment:
description: Type of version increment.
required: true
type: choice
options:
- prerelease
- preminor
- stable
concurrency:
group: release
cancel-in-progress: false
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.semver.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: semver
uses: nguyenvukhang/semver-increment@v1
with:
increment: ${{ inputs.increment == 'stable' && 'patch' || inputs.increment }}
identifier: beta
version-file: Cargo.toml
version-regex: '^version = "(.*)"'
- uses: dtolnay/rust-toolchain@stable
- name: Force Cargo.lock to update
run: cargo update --workspace
- name: Delete version branch and tag if they exist
run: |
git push origin --delete release/v${{ steps.semver.outputs.version }} || echo "Branch doesn't exist"
git push origin --delete v${{ steps.semver.outputs.version }} || echo "Tag doesn't exist"
- uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "chore: bump ${{ steps.semver.outputs.version }}"
new_branch: release/v${{ steps.semver.outputs.version }}
tag: v${{ steps.semver.outputs.version }} --force
build-nix:
needs: version
uses: ./.github/workflows/build-nix.yml
with:
channel: ${{ inputs.increment == 'stable' && 'stable' || 'beta' }}
ref: release/v${{ needs.version.outputs.version }}
build-windows:
needs: version
uses: ./.github/workflows/build-windows.yml
with:
channel: ${{ inputs.increment == 'stable' && 'stable' || 'beta' }}
ref: release/v${{ needs.version.outputs.version }}
deploy:
needs: version
secrets: inherit
uses: ./.github/workflows/deploy.yml
with:
channel: ${{ inputs.increment == 'stable' && 'stable' || 'beta' }}
ref: release/v${{ needs.version.outputs.version }}
release:
needs:
- build-nix
- build-windows
- deploy
- version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: release/v${{ needs.version.outputs.version }}
- name: Git config
run: |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git config user.name github-actions
- name: Merge release into main
run: |
git fetch --all
git switch -c main --track origin/main
git merge --no-ff --no-edit release/v${{ needs.version.outputs.version }}
git push
- if: ${{ inputs.increment == 'beta' }}
name: Merge release into beta
run: |
git switch -c beta --track origin/beta
git merge --no-ff --no-edit release/v${{ needs.version.outputs.version }}
git push
- if: ${{ inputs.increment == 'stable' }}
name: Merge release into stable
run: |
# Delete beta and stable branches if they exist
git push origin --delete beta || echo "Branch doesn't exist"
git push origin --delete stable || echo "Branch doesn't exist"
# Create stable branch from release
git checkout release/v${{ needs.version.outputs.version }}
git checkout -b stable
git push origin stable
- name: Delete release branch
run: git push origin --delete release/v${{ needs.version.outputs.version }}
- run: mkdir artifacts
- uses: actions/download-artifact@v4
with:
pattern: "build-*"
path: artifacts
- name: Add version to build file names
run: |
cd artifacts
echo Current directory contents:
ls -la
for dir in *; do
cd $dir
for file in *; do
mv $file ../${file%.zip}-${{ needs.version.outputs.version }}.zip
done
cd ..
rm -rf $dir
done
echo New directory contents:
ls -la
- uses: ncipollo/release-action@v1
with:
artifacts: artifacts/*
generateReleaseNotes: true
prerelease: ${{ contains(needs.version.outputs.version, 'beta') }}
tag: v${{ needs.version.outputs.version }}