Skip to content

Commit

Permalink
Add tag.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ecbr0wn committed Feb 26, 2024
1 parent 312b5b3 commit fd21f4d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Rust Toolchain setup
uses: dtolnay/rust-toolchain@stable
Expand All @@ -39,7 +39,7 @@ jobs:
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Rust Toolchain setup
uses: dtolnay/rust-toolchain@stable
Expand All @@ -54,19 +54,19 @@ jobs:
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
uses: github/-action/upload-sarif@v3
with:
sarif_file: rust-clippy-results.sarif
wait-for-processing: true

deploy:
runs-on: ubuntu-latest
name: Deploy
runs-on: ubuntu-latest
needs: [format, clippy]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Rust Toolchain setup
uses: dtolnay/rust-toolchain@stable
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: "Tag Release Build"
name: Release Binaries on Tag

on:
push:
tags:
- "v*"
- v*
workflow_dispatch:

env:
Expand All @@ -13,18 +13,18 @@ env:
jobs:
# Check the rust formatting
format:
name: "Rust Format Check"
name: Rust Format Check
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: "Rust Toolchain setup"
- name: Rust Toolchain setup
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: "Format Check"
- name: Format Check
uses: mbrobbel/rustfmt-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -37,7 +37,7 @@ jobs:
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Rust Toolchain setup
uses: dtolnay/rust-toolchain@stable
Expand All @@ -52,20 +52,20 @@ jobs:
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: rust-clippy-results.sarif
wait-for-processing: true

# Deploy to the production environment
deploy:
name: Deploy to the Production Environment
runs-on: ubuntu-latest
name: Deploy
needs: [format, clippy]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Rust Toolchain setup
uses: dtolnay/rust-toolchain@stable
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: Tag a release

on:
workflow_dispatch:
inputs:

version:
description: 'Tag to apply, in the form "v0.0.0"'
required: true

jobs:
tag-release:
name: Given the tag input value, check the value, update the version number of the application, commit, tag, push tag
runs-on: ubuntu-latest

steps:
- name: Check the version number from input
run: |
echo "Validating that tag is a tag is in the correct format v0.0.1"
input_version="${{ github.event.inputs.version }}"
if grep -P '^v[0-9]+\.[0-9]+\.[0-9]+' <<< "${input_version}"; then
echo "tag=${input_version}" >> $GITHUB_ENV
echo "cargo_version=version = \"${input_version:1}\"" >> $GITHUB_ENV
elif grep -P '^[0-9]+\.[0-9]+\.[0-9]+' <<< "${input_version}"; then
echo "tag=v${input_version}" >> $GITHUB_ENV
echo "cargo_version=version = \"${input_version}\"" >> $GITHUB_ENV
else
false
fi
- name: Setup GPG
run: |
echo "${{ secrets.SIGNINGKEY }}" | gpg --import
- name: Checkout code
uses: actions/checkout@v4

- name: Setup git config
run: |
# setup the username and email.
git config user.name "Tag Bot"
git config user.email "github@noser.net"
# setup gpg configuration
git config commit.gpgsign true
git config user.signingkey ${{ secrets.SIGNINGKEYHASH }}
- name: Replace the version number in the Cargo.toml files
run: |
sed -i 's/^version = .*/${{ env.cargo_version }}/g' Cargo.toml
- name: Add, push, tag, push
run: |
git add .
git commit -S -m "Release ${{ env.tag }}"
git push -f
git tag ${{ env.tag }} -s -m "Release ${{ env.tag }}"
git push origin ${{ env.tag }} -f
- name: Release Tag Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ${{env.GITHUB_REPOSITORY}}
ref: refs/tags/${{ env.tag }}
workflow: release.yml

0 comments on commit fd21f4d

Please sign in to comment.