Skip to content

Publish

Publish #75

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
release_kind:
type: choice
description: The type of release.
default: prerelease
required: true
options:
- prerelease
- start-rc
- stable
jobs:
pre-build:
name: Update version name
runs-on: ubuntu-latest
outputs:
cli-version: ${{ env.CLI_VERSION }}
vpm-version: ${{ env.VPM_VERSION }}
prerelease: ${{ steps.update-version.outputs.prerelease }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: anatawa12/something-releaser@v3
- uses: snow-actions/git-config-user@v1.0.0
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Update Version Name
id: update-version
run: |
# set version name in properties file
case "$RELEASE_KIND_IN" in
"prerelease" )
get-version -t vpm | version-next | set-version -t vpm
get-version -t cli | version-next | set-version -t cli
gh-export-variable PRERELEASE true
gh-set-output prerelease true
;;
"start-rc" )
get-version -t vpm | version-set-channel - rc 0 | set-version -t vpm
get-version -t cli | version-set-channel - rc 0 | set-version -t cli
gh-export-variable PRERELEASE true
gh-set-output prerelease true
;;
"stable" )
get-version -t vpm | version-set-channel - stable | set-version -t vpm
get-version -t cli | version-set-channel - stable | set-version -t cli
gh-export-variable PRERELEASE false
gh-set-output prerelease '' # empty string for false
;;
* )
echo "invalid release kind: $RELEASE_KIND_IN"
exit 255
;;
esac
case "$GITHUB_REF_NAME" in
master | master-* )
echo "head is master or master-*"
;;
* )
echo "invalid release kind: $RELEASE_KIND_IN is not allowd for $GITHUB_REF_NAME"
exit 255
;;
esac
gh-export-variable CLI_VERSION "$(get-version -t cli)"
gh-export-variable VPM_VERSION "$(get-version -t vpm)"
env:
RELEASE_KIND_IN: ${{ github.event.inputs.release_kind }}
- name: Commit
id: update
run: |-
# commit & tag
git commit -am "v$CLI_VERSION"
git branch releasing
git push -f -u origin releasing
build-rust:
name: Build rust
strategy:
fail-fast: false
matrix:
include:
- triple: x86_64-unknown-linux-musl
on: ubuntu-latest
rustflags: "-C target-feature=+crt-static"
- triple: aarch64-unknown-linux-musl
on: ubuntu-latest
rustflags: "-C target-feature=+crt-static"
- triple: x86_64-pc-windows-msvc
on: windows-latest
rustflags: "-C target-feature=+crt-static"
- triple: aarch64-pc-windows-msvc
on: windows-latest
rustflags: "-C target-feature=+crt-static"
- triple: x86_64-apple-darwin
on: macos-latest
- triple: aarch64-apple-darwin
on: macos-latest
triple:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
runs-on: ${{ matrix.on }}
env:
RUSTFLAGS: ${{ matrix.rustflags }}
needs: [pre-build]
steps:
- uses: actions/checkout@v3
with:
ref: 'releasing'
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.triple }}
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.triple }}
- uses: Swatinem/rust-cache@v2
with:
cache-targets: false # for release build, do not cache build artifacts
key: release # there are no elements about build result, so it's ok to share between all builds
- name: Build
run: cargo build --target ${{ matrix.triple }} --release --verbose
- name: Move artifacts
shell: bash
run: |-
mkdir artifacts
pushd target/${{ matrix.triple }}/release
for f in vrc-get*; do
mv $f "../../../artifacts/${{ matrix.triple }}-$f"
done
popd
- uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.triple }}
path: artifacts/*
publish-crates-io:
name: Publish to crates.io
environment:
name: crates.io
url: https://crates.io/crates/vrc-get
runs-on: ubuntu-latest
needs: [pre-build, build-rust]
steps:
- uses: actions/checkout@v3
with:
ref: 'releasing'
fetch-depth: 1
submodules: recursive
- name: Publish vpm to CARGO
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: cargo publish --package vrc-get-vpm --no-verify
- name: Publish CARGO
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: cargo publish --package vrc-get --no-verify
publish-to-homebrew:
name: Publish to homebrew
if: ${{ !needs.pre-build.outputs.prerelease }}
environment:
name: homebrew-core
url: https://github.com/anatawa12/homebrew-core
runs-on: macos-latest
needs: [pre-build, build-rust]
env:
CLONE_TAP_TO: brew-tap
steps:
#- uses: snow-actions/git-config-user@v1.0.0
- run: git config --global user.name "github-actions[bot]" &&
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: update brew
run: brew update && brew update
- name: checkout tap
uses: actions/checkout@v3
with:
repository: anatawa12/homebrew-core
path: ${{ env.CLONE_TAP_TO }}
token: ${{ secrets.BREW_GITHUB_PAT }}
- name: configure tap
run: |-
TAP_PATH="$(brew --repository "anatawa12/core")"
mkdir -p "$(dirname "$TAP_PATH")"
ln -s "$(readlink -f -- "$CLONE_TAP_TO")" "$TAP_PATH"
# configure
cd "$CLONE_TAP_TO"
git remote set-head origin -a
- name: Create update pr for anatawa12/homebrew-core
env:
VERSION: ${{ needs.pre-build.outputs.cli-version }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.BREW_GITHUB_PAT }}
run: |-
brew bump-formula-pr \
anatawa12/core/vrc-get \
--url "https://github.com/anatawa12/vrc-get/archive/refs/tags/v${VERSION}.tar.gz"
publish-to-github:
name: Publish to GitHub
environment:
name: master branch
url: https://github.com/anatawa12/vrc-get/releases/v${{ needs.pre-build.outputs.cli-version }}
permissions:
contents: write
runs-on: ubuntu-latest
needs: [pre-build, build-rust]
env:
CLI_VERSION: ${{ needs.pre-build.outputs.cli-version }}
VPM_VERSION: ${{ needs.pre-build.outputs.vpm-version }}
steps:
- uses: actions/checkout@v3
with:
ref: 'releasing'
fetch-depth: 2
submodules: recursive
token: ${{ secrets.MASTER_GITHUB_PAT }}
# tools
- uses: anatawa12/something-releaser@v3
- uses: snow-actions/git-config-user@v1.0.0
- uses: dtolnay/rust-toolchain@stable
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: assets
pattern: artifacts-*
merge-multiple: true
- name: Push tag
run: |-
# set tag and publish current version
git tag "v$CLI_VERSION"
git tag "vpm-v$VPM_VERSION"
git push --tags
# create master and push
git switch -c master
git fetch origin master --depth=1
git log --all --graph
git push -u origin master
sleep 1
- name: create release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |-
gh release create ${{ needs.pre-build.outputs.prerelease && '--prerelease' || '' }} --verify-tag "v$CLI_VERSION" assets/*
rm -rf outputs assets
- name: prepare next release & push
if: ${{ !needs.pre-build.outputs.prerelease }}
run: |
get-version -t cli | version-next | version-set-channel - beta 0 | set-version -t cli
get-version -t vpm | version-next | version-set-channel - beta 0 | set-version -t vpm
CLI_NEXT="$(get-version -t cli | version-stable)"
git commit -am "chore: prepare for next version: $CLI_NEXT"
git push
cleanup:
name: Cleanup
if: ${{ !failure() && !cancelled() }}
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- pre-build
- build-rust
- publish-crates-io
- publish-to-homebrew
- publish-to-github
env:
CLI_VERSION: ${{ needs.pre-build.outputs.cli-version }}
VPM_VERSION: ${{ needs.pre-build.outputs.vpm-version }}
steps:
- uses: actions/checkout@v3
with:
ref: 'releasing'
fetch-depth: 2
- name: remove releasing branch
run: git push --delete origin releasing