Skip to content

Commit

Permalink
Tag workflow (#19)
Browse files Browse the repository at this point in the history
* Fix issue with sed delimiter
* update yml name to release-lib.yml
* Change the name of the release-example.yml
* Change PAT to GITHUB_TOKEN
* Change build.yml
* Change resolver
  • Loading branch information
a1ecbr0wn authored Feb 25, 2024
1 parent 489a285 commit 723c8ca
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 23 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Checkout
uses: actions/checkout@v4

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

- uses: mbrobbel/rustfmt-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# More details at https://github.com/rust-lang/rust-clippy
# and https://rust-lang.github.io/rust-clippy/

name: rust-clippy analyze
name: Rust Clippy Analyze

on:
push:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release-example.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: tag-release-example
name: Release Example on Tag

on:
workflow_dispatch:
Expand All @@ -11,7 +11,7 @@ on:
jobs:
# Check the rust formatting
format:
name: rust-format
name: Rust Format
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -29,7 +29,7 @@ jobs:

# Build the Linux release artifacts
tag-release-example:
name: tag-release example
name: Tag Release Example
runs-on: ubuntu-latest
needs: format
strategy:
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
run: md5sum --tag snapcraft-rust-example-${{ matrix.TARGET }}.tar.gz > snapcraft-rust-example-${{ matrix.TARGET }}.md5

- name: Upload the artifact with the workflow run
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: snapcraft-rust-example-${{ matrix.TARGET }}-${{ github.event.inputs.example_version }}
path: snapcraft-rust-example-${{ matrix.TARGET }}.*
Expand All @@ -85,7 +85,7 @@ jobs:
uses: actions/checkout@v4

- name: Download all release artifacts from the workflow
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

- name: Create Example Release
uses: marvinpinto/action-automatic-releases@latest
Expand All @@ -107,8 +107,8 @@ jobs:
- name: Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PAT }}
token: ${{ secrets.GITHUB_TOKEN }}
repo: a1ecbr0wn/snapcraft
ref: refs/heads/main
ref: ${{ github.ref }}
workflow: snap.yml
inputs: '{ "snap_version": "${{ github.event.inputs.example_version }}" }'
4 changes: 2 additions & 2 deletions .github/workflows/release-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
- name: Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PAT }}
token: ${{ secrets.GITHUB_TOKEN }}
repo: a1ecbr0wn/snapcraft
ref: refs/heads/main
ref: ${{ github.ref }}
workflow: release-example.yml
inputs: '{ "example_version": "${{ github.ref_name }}" }'
5 changes: 3 additions & 2 deletions .github/workflows/snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ jobs:
- 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 snapcraft-rust-example-${{ env.snap_version }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: snapcraft-rust-example-${{ env.snap_version }}
base: main
delete-branch: true
title: 'Update of snap for snapcraft-rust-example tag ${{ env.snap_version }}'
body: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
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 "snapcraft_dep_version=snapcraft = { path = "../snapcraft", version = \"${input_version:1}\"}" >> $GITHUB_ENV
echo "snapcraft_dep_version=snapcraft = { path = \"../snapcraft\", 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 "snapcraft_dep_version=snapcraft = { path = "../snapcraft", version = \"${input_version}\"}" >> $GITHUB_ENV
echo "snapcraft_dep_version=snapcraft = { path = \"../snapcraft\", version = \"${input_version}\" }" >> $GITHUB_ENV
else
false
fi
Expand All @@ -51,8 +51,8 @@ jobs:
run: |
sed -i 's/^version = .*/${{ env.cargo_version }}/g' snapcraft/Cargo.toml
sed -i 's/^version = .*/${{ env.cargo_version }}/g' snapcraft-rust-example/Cargo.toml
sed -i 's/^snapcraft = { path = "../snapcraft", version = .*/${{ env.snapcraft_dep_version }}/g' snapcraft-rust-example/Cargo.toml
sed -i 's#^snapcraft = { path = "../snapcraft", version = .*#${{ env.snapcraft_dep_version }}#g' snapcraft-rust-example/Cargo.toml
- name: Add, push, tag, push
run: |
git add .
Expand All @@ -67,4 +67,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ${{env.GITHUB_REPOSITORY}}
ref: refs/tags/${{ env.tag }}
workflow: release.yml
workflow: release-lib.yml
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]

resolver = "2"
members = [
"snapcraft",
"snapcraft-rust-example",
Expand Down
4 changes: 2 additions & 2 deletions snapcraft-rust-example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snapcraft-rust-example"
version = "0.3.0"
version = "0.3.5"
edition = "2021"
authors = ["Alec Brown <alec@noser.net>"]
description = "Test application for snapcraft rust library."
Expand All @@ -19,4 +19,4 @@ path = "src/main.rs"
name = "snapcraft-rust-example"

[dependencies]
snapcraft = { path = "../snapcraft", version = "0.3.0"}
snapcraft = { path = "../snapcraft", version = "0.3.5" }
2 changes: 1 addition & 1 deletion snapcraft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snapcraft"
version = "0.3.0"
version = "0.3.5"
edition = "2021"
authors = ["Alec Brown <alec@noser.net>"]
description = "Access to snapcraft environment."
Expand Down

0 comments on commit 723c8ca

Please sign in to comment.