Skip to content

Commit

Permalink
Deployment pipeline for staging/pre-release (#8)
Browse files Browse the repository at this point in the history
Rename deploy pipeline to deploy_release
Implement deploy_prerelease pipeline for staging branch
  • Loading branch information
Kitt3120 committed Nov 10, 2023
1 parent 053ee15 commit 90c42db
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/deploy_prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy pre-release
on:
push:
branches: [staging]
jobs:
github_release:
name: Deploy GitHub (pre-release)
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-unknown-linux-gnu
override: true
- name: Package
uses: actions-rs/cargo@v1
with:
command: package
args: --all-features
- name: Read crate name
id: crate_name
run: echo "crate_name=$(cargo read-manifest | jq -r .name)" >> $GITHUB_OUTPUT
- name: Read version
id: version
run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT
- name: Read git commit hash
id: commit_hash
run: echo "commit_hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions
run: gh release create "${{ steps.commit_hash.outputs.commit_hash }}" --repo="$GITHUB_REPOSITORY" --title="Release ${{ steps.version.outputs.version }}" --generate-notes --latest --prerelease "./target/package/${{ steps.crate_name.outputs.crate_name }}-${{ steps.version.outputs.version }}.crate"
54 changes: 54 additions & 0 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deploy release
on:
push:
branches: [main]
jobs:
crates_io:
name: Deploy crates.io (release)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-unknown-linux-gnu
override: true
- name: Login to crates.io
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
uses: actions-rs/cargo@v1
with:
command: publish
github_release:
name: Deploy GitHub (release)
needs: crates_io
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-unknown-linux-gnu
override: true
- name: Package
uses: actions-rs/cargo@v1
with:
command: package
args: --all-features
- name: Read crate name
id: crate_name
run: echo "crate_name=$(cargo read-manifest | jq -r .name)" >> $GITHUB_OUTPUT
- name: Read version
id: version
run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions
run: gh release create "${{ steps.version.outputs.version }}" --repo="$GITHUB_REPOSITORY" --title="Release ${{ steps.version.outputs.version }}" --generate-notes --latest "./target/package/${{ steps.crate_name.outputs.crate_name }}-${{ steps.version.outputs.version }}.crate"

0 comments on commit 90c42db

Please sign in to comment.