Skip to content

Commit c2c943b

Browse files
committed
chore(workflow): clean up rust.yml for clarity and consistency
- Removed commented-out sections and unnecessary comments for a more streamlined workflow file. - Ensured consistent formatting and clarity in job definitions and steps.
1 parent 58162e4 commit c2c943b

1 file changed

Lines changed: 12 additions & 44 deletions

File tree

.github/workflows/rust.yml

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches: ["master"]
66

7-
# Grant permissions for release-please to create PRs, write releases, and commit files
87
permissions:
98
contents: write
109
pull-requests: write
@@ -15,48 +14,25 @@ concurrency:
1514

1615
env:
1716
CARGO_TERM_COLOR: always
18-
# IMPORTANT: Set this to the name of your crate as defined in Cargo.toml
19-
# This is used by release-please and for naming artifacts.
2017
CRATE_NAME: rust-commit-tracker
2118

2219
jobs:
23-
# This job handles versioning, changelog generation, and creating Release PRs.
24-
# When a Release PR is merged, it creates the Git tag and GitHub Release.
2520
release-please:
2621
runs-on: ubuntu-latest
2722
outputs:
2823
release_created: ${{ steps.release.outputs.release_created }}
2924
tag_name: ${{ steps.release.outputs.tag_name }}
30-
# 'version' output by release-please is the raw version, e.g., "1.2.3"
31-
# 'tag_name' is typically "v1.2.3"
3225
version: ${{ steps.release.outputs.version }}
33-
upload_url: ${{ steps.release.outputs.upload_url }} # URL for uploading release assets
26+
upload_url: ${{ steps.release.outputs.upload_url }}
3427
steps:
3528
- uses: googleapis/release-please-action@v4
3629
id: release
3730
with:
3831
release-type: rust
3932
token: ${{ secrets.GITHUB_TOKEN }}
40-
# Explicitly provide the package name if Cargo.toml is not at the root,
41-
# or if you want to be very specific.
42-
43-
# Optional: If you want minor bumps for 'feat' before v1.0.0
44-
# bump-minor-pre-major: true
45-
# Optional: If you want patch bumps for 'fix' before v1.0.0
46-
# bump-patch-for-minor-pre-major: true
47-
# Optional: Customize the path to your changelog
48-
# changelog-path: CHANGELOG.md
49-
50-
# Your existing test job - good to keep!
51-
# release-please will create PRs based on commits to master.
52-
# Ensure your master branch is protected and requires tests to pass.
33+
5334
test:
5435
runs-on: ubuntu-latest
55-
# You might want this to run on PRs to master as well,
56-
# especially for the Release PRs created by release-please.
57-
# on:
58-
# pull_request:
59-
# branches: ["master"]
6036
steps:
6137
- uses: actions/checkout@v4
6238
- name: Install Rust toolchain
@@ -66,35 +42,32 @@ jobs:
6642
- name: Run tests
6743
run: cargo test --verbose
6844

69-
# This job builds the binaries for different targets.
70-
# It only runs IF a release was actually created by release-please (i.e., Release PR merged).
7145
build-binaries:
72-
needs: [release-please, test] # Ensure tests pass and release is initiated
46+
needs: [release-please, test]
7347
if: needs.release-please.outputs.release_created == 'true'
74-
runs-on: ${{ matrix.os }} # Use the OS specified in the matrix
48+
runs-on: ${{ matrix.os }}
7549
strategy:
7650
matrix:
7751
include:
7852
- target: x86_64-pc-windows-gnu
79-
os: ubuntu-latest # Cross-compile Windows on Linux
53+
os: ubuntu-latest
8054
asset_name_suffix: .exe
8155
archive_format: zip
8256
- target: x86_64-unknown-linux-gnu
8357
os: ubuntu-latest
8458
asset_name_suffix: ""
8559
archive_format: tar.gz
8660
- target: x86_64-apple-darwin
87-
os: macos-latest # Build macOS on macOS
61+
os: macos-latest
8862
asset_name_suffix: ""
8963
archive_format: tar.gz
9064
steps:
9165
- uses: actions/checkout@v4
92-
# No need for fetch-depth: 0 here, building from the release commit.
9366

9467
- name: Install Rust toolchain for target
9568
uses: dtolnay/rust-toolchain@stable
9669
with:
97-
toolchain: stable # Or a specific version
70+
toolchain: stable
9871
targets: ${{ matrix.target }}
9972

10073
- name: Install cross-compilation tools (for Windows target on Linux)
@@ -113,11 +86,9 @@ jobs:
11386
11487
- name: Determine Asset Names
11588
id: asset_names
116-
shell: bash # Ensure bash is used for consistency
89+
shell: bash
11790
run: |
118-
# Use the CRATE_NAME from env for the binary's base name
11991
local_crate_name="${{ env.CRATE_NAME }}"
120-
# Use the tag_name from release-please for versioning in the archive
12192
local_tag_name="${{ needs.release-please.outputs.tag_name }}"
12293
12394
binary_filename="${local_crate_name}${{ matrix.asset_name_suffix }}"
@@ -129,7 +100,7 @@ jobs:
129100
echo "packaged_binary_name=${binary_filename}" >> $GITHUB_OUTPUT
130101
131102
- name: Package binary
132-
shell: bash # Ensure bash is used
103+
shell: bash
133104
run: |
134105
mkdir -p dist
135106
cp "${{ steps.asset_names.outputs.binary_path }}" "dist/${{ steps.asset_names.outputs.packaged_binary_name }}"
@@ -139,7 +110,7 @@ jobs:
139110
else
140111
tar -czf "${{ steps.asset_names.outputs.asset_upload_name }}" "${{ steps.asset_names.outputs.packaged_binary_name }}"
141112
fi
142-
cd .. # Go back to the original directory
113+
cd ..
143114
144115
- name: Upload Release Asset
145116
uses: actions/upload-release-asset@v1
@@ -149,22 +120,19 @@ jobs:
149120
upload_url: ${{ needs.release-please.outputs.upload_url }}
150121
asset_path: ${{ steps.asset_names.outputs.archive_path }}
151122
asset_name: ${{ steps.asset_names.outputs.asset_upload_name }}
152-
asset_content_type: application/octet-stream # Or specific types like application/zip
123+
asset_content_type: application/octet-stream
153124

154-
# Optional: Job to publish your crate to crates.io
155125
publish-crate:
156-
needs: [release-please, test] # Depends on a release being created and tests passing
126+
needs: [release-please, test]
157127
if: needs.release-please.outputs.release_created == 'true'
158128
runs-on: ubuntu-latest
159129
steps:
160130
- uses: actions/checkout@v4
161131
with:
162-
# Checkout the specific commit that was tagged for this release
163132
ref: ${{ needs.release-please.outputs.tag_name }}
164133

165134
- name: Install Rust toolchain
166135
uses: dtolnay/rust-toolchain@stable
167136

168137
- name: Publish to crates.io
169138
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
170-
# Ensure CARGO_REGISTRY_TOKEN is set as a secret in your GitHub repository settings

0 commit comments

Comments
 (0)