Update release.yml #46
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 | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- v[0-9]+.* | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: taiki-e/create-gh-release-action@v1 | |
with: | |
token: ${{ secrets.RELEASE_GH_TOKEN }} | |
upload-public-assets: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
default: true | |
- name: Install Ubuntu dependencies | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: export DEBIAN_FRONTEND=noninteractive && sudo apt update && sudo apt install -y librust-alsa-sys-dev | |
- name: Add fake empty dependency | |
shell: bash | |
run: crates/fake-glass.sh | |
- name: Build and upload | |
uses: taiki-e/upload-rust-binary-action@v1 | |
with: | |
bin: steel | |
token: ${{ secrets.RELEASE_GH_TOKEN }} | |
upload-private-assets: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
default: true | |
- name: Install Ubuntu dependencies | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: export DEBIAN_FRONTEND=noninteractive && sudo apt update && sudo apt install -y librust-alsa-sys-dev | |
- name: Clone glass dependency | |
uses: actions/checkout@v3 | |
with: | |
repository: TicClick/glass | |
path: crates/glass | |
token: ${{ secrets.GH_TOKEN }} | |
- name: patch git url | |
shell: bash | |
run: | | |
git config --global url."https://${{ secrets.GH_TOKEN }}@github.com".insteadOf ssh://[email protected] | |
- name: Build (private) | |
uses: taiki-e/upload-rust-binary-action@v1 | |
env: | |
# https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli -- `git clone` uses private access token | |
CARGO_NET_GIT_FETCH_WITH_CLI: true | |
with: | |
dry-run: true | |
bin: steel | |
features: glass | |
- name: Upload (private) | |
shell: bash | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
ASSET_GIST_HASH: ${{ secrets.ASSET_GIST_HASH }} | |
run: | | |
platform_binary=$( ls steel-* ) | |
git clone https://"${{ secrets.GH_TOKEN }}"@gist.github.com/TicClick/${ASSET_GIST_HASH}.git && cd ${ASSET_GIST_HASH} | |
git config user.name "TicClick" && git config user.email "[email protected]" | |
cp "../${platform_binary}" . && git add "${platform_binary}" | |
git commit -m "${{ github.ref_name }}: update ${platform_binary}" | |
for i in {0..4}; do | |
if ! git push origin master ; then | |
if [[ $i -eq 4 ]]; then | |
echo "git pull/push: failed after 4 retries" && exit 1 | |
fi | |
git pull -s ours | |
else | |
break | |
fi | |
done | |
update-private-metadata: | |
runs-on: ubuntu-latest | |
needs: upload-private-assets | |
steps: | |
- name: Tag all assets | |
shell: bash | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
ASSET_GIST_HASH: ${{ secrets.ASSET_GIST_HASH }} | |
run: | | |
gh gist clone "${ASSET_GIST_HASH}" | |
cd "${ASSET_GIST_HASH}" | |
git tag ${{ github.ref_name }} | |
git push --tags | |
- name: Update releases.json | |
shell: bash | |
run: .github/update-private-metadata.py | |
env: | |
ASSET_GIST_OWNER: TicClick | |
TAG_NAME: ${{ github.ref_name }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
ASSET_GIST_HASH: ${{ secrets.ASSET_GIST_HASH }} | |
METADATA_GIST_HASH: ${{ secrets.METADATA_GIST_HASH }} |