Skip to content

Release Snowball

Release Snowball #38

Workflow file for this run

name: 'Release Snowball'
on:
workflow_dispatch:
inputs:
beta:
description: 'Is this a beta release?'
required: false
type: 'boolean'
default: false
update-version-type:
description: 'The type of version update to perform'
required: false
default: 'none'
type: 'choice'
options:
- 'patch'
- 'minor'
- 'major'
- 'prerelease'
- 'prepatch'
- 'preminor'
- 'premajor'
- 'none'
create-release:
description: 'Create a release on GitHub?'
required: false
type: 'boolean'
default: true
jobs:
update_version:
name: 'Update Version'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Initialize Git
run: |
git config --global user.name 'Git bot'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
- name: Update Version
if: ${{ github.event.inputs.update-version-type != 'none' }}
run: |
npx semver -i ${{ github.event.inputs.update-version-type }} $(cat snowball.version.info) ${{ github.event.inputs.beta == 'true' && '--preid beta' }} -n false > snowball.version.info
# Remove the last line break
truncate -s -1 snowball.version.info
git add snowball.version.info
git commit -m "Update version to $(cat snowball.version.info)"
git push --follow-tags
check_version:
name: 'Check Version'
needs: [update_version]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check Version
run: |
echo "Current version: $(cat snowball.version.info)"
pre_build:
name: 'Create Tag'
needs: [update_version]
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.export_tag.outputs.release_tag }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Initialize Git
run: |
git config --global user.name 'Git bot'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
- name: Create Tag
run: |
set -x
git pull
git tag $(cat snowball.version.info)
git push origin --tags
- name: Export Tag
id: export_tag
run: |
echo "release_tag=$(cat snowball.version.info)" >> "$GITHUB_OUTPUT"
release_linux:
name: 'Release Linux'
runs-on: ubuntu-20.04
needs: [pre_build]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Display info
run: |
echo "Release tag: ${{ needs.pre_build.outputs.release_tag }}"
echo "Version: $(cat snowball.version.info)"
- name: Install dependencies
run: bash ./scripts/install-deps.sh
- name: Prepare build
run: bash ./scripts/cmake-release.sh
- name: Build
run: |
cd build
make -j$(nproc)
- name: Package
run: |
cd build
tar -czf snowball-linux-x86_64.tar.gz snowball libSnowball.so
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: snowball-linux-x86_64.tar.gz
path: build/snowball-linux-x86_64.tar.gz
release_source:
name: 'Release Source'
runs-on: ubuntu-latest
needs: [pre_build]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Package
run: |
mkdir source
rsync -av --progress --exclude='build' --exclude='.git' --exclude='.github' --exclude='*.tar.gz' --exclude='*.zip' --exclude='*.7z' --exclude='*.rar' --exclude='*.tar' . source
tar -czf snowball-source.tar.gz source
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: snowball-source.tar.gz
path: snowball-source.tar.gz
fetch_artifacts:
name: 'Fetch Artifacts'
runs-on: ubuntu-latest
needs: [release_linux, release_source]
steps:
- name: Download Linux Artifact
uses: actions/download-artifact@v2
with:
name: snowball-linux-x86_64.tar.gz
create_release:
permissions: write-all
name: 'Create Release'
runs-on: ubuntu-latest
if: ${{ github.event.inputs.create-release == 'true' }}
needs: [release_linux, release_source, pre_build, check_version, fetch_artifacts]
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/download-artifact@v3
- name: Check release tag
run: echo ${{ needs.pre_build.outputs.release_tag }}
- name: Show the whole directory
run: ls -la
- name: Create Release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
automatic_release_tag: ${{ needs.pre_build.outputs.release_tag }}
prerelease: false
title: 'Snowball ${{ needs.pre_build.outputs.release_tag }} Release'
files: |
snowball-linux-x86_64.tar.gz
snowball-source.tar.gz
post_release:
name: 'Release Summary'
runs-on: ubuntu-latest
if: ${{ github.event.inputs.create-release == 'true' }}
needs: [pre_build, fetch_artifacts]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Write job summary
run: |
echo "### Release completed! :rocket:" >> $GITHUB_STEP_SUMMARY
echo "Version: $(cat snowball.version.info)" >> $GITHUB_STEP_SUMMARY
echo "Release tag: ${{ needs.pre_build.outputs.release_tag }}" >> $GITHUB_STEP_SUMMARY