version: '1.0' mode: parallel stages: - clone - test - native-release - cargo-publish steps: main_clone: title: Clone main repository type: git-clone stage: clone git: github repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} revision: ${{CF_REVISION}} build_test: type: build stage: test title: Build test image dockerfile: Dockerfile-test image_name: clux/muslrust tag: test when: steps: - name: main_clone on: - success test: title: Run tests stage: test image: ${{build_test}} working_directory: ${{main_clone}} commands: - cargo fmt -v --all -- --check - cargo clippy -v --locked --all - cargo test -v --locked --all when: steps: - name: build_test on: - success build_release: title: Build release stage: native-release image: clux/muslrust:stable working_directory: ${{main_clone}} commands: - cargo build --release -v --locked --all when: steps: - name: main_clone on: - success compress_release: title: Compress release executable stage: native-release image: guangie88/releaser:alpine_upx-3_ghr-0.12 working_directory: ${{main_clone}} commands: - mkdir -p target/x86_64-unknown-linux-musl/release-compressed - cd target/x86_64-unknown-linux-musl - cp release/httpose release-compressed/httpose_linux_amd64 - upx --best --lzma release-compressed/httpose_linux_amd64 when: steps: - name: build_release on: - success upload_release: title: Upload release executable stage: native-release image: guangie88/releaser:alpine_upx-3_ghr-0.12 working_directory: ${{main_clone}}/target/x86_64-unknown-linux-musl/release-compressed commands: - |- ghr -t ${{GITHUB_TOKEN}} -u ${{CF_REPO_OWNER}} -r ${{CF_REPO_NAME}} \ -c ${{CF_REVISION}} -replace ${{CF_RELEASE_TAG}} httpose_linux_amd64 when: condition: all: is_master_branch: '"${{CF_BRANCH}}" == "master"' is_release_tag: 'match("${{CF_RELEASE_TAG}}", "^v\\d+\\.\\d+\\.\\d+$", false)' steps: - name: compress_release on: - success cargo_cli_publish: title: Publish to Cargo for CLI stage: cargo-publish image: clux/muslrust:stable working_directory: ${{main_clone}} commands: - cargo login ${{CRATES_TOKEN}} - cargo publish retry: maxAttempts: 3 delay: 10 when: condition: all: is_master_branch: '"${{CF_BRANCH}}" == "master"' is_release_tag: 'match("${{CF_RELEASE_TAG}}", "^v\\d+\\.\\d+\\.\\d+$", false)' steps: - name: main_clone on: - success