Rust create release fix action #9
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 | |
on: | |
push: | |
branches: | |
- v0.* | |
jobs: | |
build: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ^1.15 | |
id: go | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Get dependencies | |
run: go get -v -t -d ./... | |
- name: Build | |
run: | | |
GOOS=linux GOARCH=amd64 go build -ldflags '-extldflags "-fno-PIC -static"' -buildmode pie -tags 'osusergo netgo static_build' -o grotsky-linux ./cmd/grotsky/ | |
GOOS=darwin GOARCH=amd64 go build -ldflags '-extldflags "-fno-PIC -static"' -buildmode pie -tags 'osusergo netgo static_build' -o grotsky-macos ./cmd/grotsky/ | |
- name: Extract branch name | |
shell: bash | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
id: extract_branch | |
- name: Prepare Release Linux | |
run: | | |
mv grotsky-linux grotsky | |
tar -czvf grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz grotsky | |
- name: Prepare Release Mac | |
run: | | |
mv grotsky-macos grotsky | |
tar -czvf grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz grotsky | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.extract_branch.outputs.branch }} | |
release_name: Release ${{ steps.extract_branch.outputs.branch }} | |
body: | | |
Automated Release | |
draft: false | |
prerelease: false | |
- name: Upload Release Linux | |
id: upload-release-linux | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ./grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz | |
asset_name: grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz | |
asset_content_type: application/gzip | |
- name: Upload Release Mac | |
id: upload-release-macos | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ./grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz | |
asset_name: grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz | |
asset_content_type: application/gzip | |
build_rust: | |
name: Build Rust version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install latest stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt, clippy | |
- name: Install deps | |
run: | | |
sudo apt-get install make | |
rustup target add x86_64-apple-darwin | |
- name: Build for linux | |
run: | | |
cd rewrite_in_rust | |
cargo build --release | |
mv target/release/grotsky-rs ../grotsky-rs-linux | |
- name: Extract branch name | |
shell: bash | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
id: extract_branch | |
- name: Prepare Release Linux | |
run: | | |
mv grotsky-rs-linux grotsky | |
tar -czvf grotsky-rs-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz grotsky | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.extract_branch.outputs.branch }}-rs | |
release_name: Release ${{ steps.extract_branch.outputs.branch }}-rs | |
body: | | |
Automated Release | |
draft: false | |
prerelease: false | |
- name: Upload Release Linux | |
id: upload-release-linux | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ./grotsky-rs-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz | |
asset_name: grotsky-rs-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz | |
asset_content_type: application/gzip |