Skip to content

Commit

Permalink
Add tag.yml (#20)
Browse files Browse the repository at this point in the history
* Add tag.yml
* Remove PAT
  • Loading branch information
a1ecbr0wn authored Feb 25, 2024
1 parent b772513 commit 6e48cf1
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

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

- name: Toolchain setup
uses: dtolnay/rust-toolchain@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ on:
jobs:
format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "Tag Release Build"
name: Release Binaries on Tag

on:
push:
Expand All @@ -9,7 +9,7 @@ on:

jobs:
tag-release:
name: Tag Release Build
name: Build tag as a release
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -19,7 +19,7 @@ jobs:

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

- name: Toolchain setup
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:

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

- name: Toolchain setup
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:

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

- name: Toolchain setup
uses: dtolnay/rust-toolchain@master
Expand All @@ -113,7 +113,7 @@ jobs:

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

- name: Create CLI Release
uses: softprops/action-gh-release@v1
Expand All @@ -136,7 +136,7 @@ jobs:
- name: Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PAT }}
token: ${{ secrets.GITHUB_TOKEN }}
repo: a1ecbr0wn/alienware-wmi
ref: refs/heads/main
workflow: snap.yml
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/snap.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "generate-snap"
name: Generate Snap

on:
workflow_dispatch:
Expand All @@ -10,11 +10,11 @@ on:

jobs:
generate-formula:
name: "Generate a snap file"
name: Generate a snap file
runs-on: ubuntu-latest
steps:

- name: "Set Version"
- name: Set Version
run: |
input_version="${{ github.event.inputs.snap_version }}"
if [ "${#input_version}" -eq "0" ]; then
Expand All @@ -25,27 +25,28 @@ jobs:
- run: echo 'Release ${{ env.snap_version }}'

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

- name: "Create the snap from the template"
- name: Create the snap from the template
run: |
cp template/snapcraft.yaml snapcraft.yaml
cat snapcraft.yaml
sed -i 's/:snap_version/${{ env.snap_version }}/' snapcraft.yaml
echo " --- "
cat snapcraft.yaml
- name: "Create Pull Request"
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PAT }}
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update snap to alienware-cli-${{ env.snap_version }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: alienware-cli-${{ env.snap_version }}
base: main
delete-branch: true
title: 'Update of snap for alienware-cli tag ${{ env.snap_version }}'
body: |
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
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
echo "alienware_dep_version=alienware = { path = \"../alienware\", 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
echo "alienware_dep_version=alienware = { path = \"../alienware\", 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' alienware/Cargo.toml
sed -i 's/^version = .*/${{ env.cargo_version }}/g' alienware-cli/Cargo.toml
sed -i 's#^alienware = { path = "../alienware", version = .*#${{ env.alienware_dep_version }}#g' alienware-cli/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
4 changes: 2 additions & 2 deletions alienware_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ name = "alienware-cli"

[dependencies]
alienware = { path = "../alienware", version = "1.0.11"}
clap = { version = "4.4", features = ["derive"] }
clap = { version = "4.5", features = ["derive"] }
json = "0.12.4"
regex = "1"
snapcraft = "0.3"
snapcraft = "0.4"

0 comments on commit 6e48cf1

Please sign in to comment.