Skip to content

Commit

Permalink
Add GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zireael-N committed Jul 18, 2020
1 parent d20b786 commit 8a7ba36
Showing 1 changed file with 139 additions and 0 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Based on https://github.com/BurntSushi/ripgrep/blob/ffd4c9ccba0ffc74270a8d3ae75f11a7ba7a1a64/.github/workflows/release.yml

name: release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- name: Create artifacts directory
run: mkdir artifacts

- name: Get the release version from the tag
run: |
echo "::set-env name=VERSION::${GITHUB_REF#refs/tags/}"
echo "version is: ${{ env.VERSION }}"
- name: Create GitHub release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}

- name: Save release upload URL to artifact
run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url

- name: Save version number to artifact
shell: bash
run: echo "${{ env.VERSION }}" | sed "s/^v//" > artifacts/release-version

- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts

build-release:
name: build-release
needs: ['create-release']
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos, win-msvc, win-gnu, win32-msvc, win32-gnu]
include:
- build: linux
os: ubuntu-18.04
rust: stable
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: win-msvc
os: windows-2019
rust: stable
target: x86_64-pc-windows-msvc
- build: win-gnu
os: windows-2019
rust: stable
target: x86_64-pc-windows-gnu
- build: win32-msvc
os: windows-2019
rust: stable
target: i686-pc-windows-msvc
- build: win32-gnu
os: windows-2019
rust: stable
target: i686-pc-windows-gnu

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}

- name: Get release download URL
uses: actions/download-artifact@v1
with:
name: artifacts
path: artifacts

- name: Set release upload URL and release version
shell: bash
run: |
release_upload_url="$(cat artifacts/release-upload-url)"
echo "::set-env name=RELEASE_UPLOAD_URL::$release_upload_url"
echo "release upload url: $RELEASE_UPLOAD_URL"
release_version="$(cat artifacts/release-version)"
echo "::set-env name=RELEASE_VERSION::$release_version"
echo "release version: $RELEASE_VERSION"
- name: Build release binaries
run: cargo build --verbose --release

- name: Strip release binaries
if: matrix.build == 'linux' || matrix.build == 'macos'
run: |
strip "target/release/generate_yaml_from_dir"
strip "target/release/generate_yaml_from_one"
strip "target/release/localize_npc_names"
- name: Build archive
shell: bash
run: |
release="bw_locale_generator-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
mkdir -p "$release"
if [ "${{ matrix.os }}" = "windows-2019" ]; then
cp "target/release/generate_yaml_from_dir.exe" "$release/"
cp "target/release/generate_yaml_from_one.exe" "$release/"
cp "target/release/localize_npc_names.exe" "$release/"
7z a "$release.zip" "$release"
echo "::set-env name=ASSET::$release.zip"
else
cp "target/release/generate_yaml_from_dir" "$release/"
cp "target/release/generate_yaml_from_one" "$release/"
cp "target/release/localize_npc_names" "$release/"
tar czf "$release.tar.gz" "$release"
echo "::set-env name=ASSET::$release.tar.gz"
fi
- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream

0 comments on commit 8a7ba36

Please sign in to comment.