Skip to content

Commit adf0290

Browse files
authored
Merge pull request #96 from Lordfirespeed/actions-housekeeping
Actions/Workflows housekeeping
2 parents 9de949b + c18cd03 commit adf0290

File tree

5 files changed

+83
-33
lines changed

5 files changed

+83
-33
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ charset = utf-8
88
indent_style = space
99
indent_size = 4
1010

11+
[*.yml]
12+
indent_size = 2
13+
1114
[*.{cs,vb}]
1215
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules
1316
csharp_new_line_before_open_brace = all

.github/workflows/publish.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@ on:
66

77
jobs:
88
nuget:
9+
name: Publish NuGet Package
910
runs-on: ubuntu-latest
1011
steps:
11-
- uses: actions/checkout@v2
12-
- uses: actions/setup-dotnet@v3
12+
- name: Checkout ref that triggered workflow
13+
uses: actions/checkout@v4
14+
15+
- name: Setup .NET
16+
uses: actions/setup-dotnet@v4
1317
with:
1418
dotnet-version: '7'
1519

1620
- name: Fetch Latest .nupkg
17-
uses: dsaltares/fetch-gh-release-asset@0efe227dedb360b09ea0e533795d584b61c461a9
21+
uses: dsaltares/fetch-gh-release-asset@1.1.1
1822
with:
19-
token: "${{ secrets.GITHUB_TOKEN }}"
2023
version: "tags/${{ github.ref_name }}"
2124
file: "tcli.${{ github.ref_name }}.nupkg"
2225
target: "tcli.nupkg"
2326

24-
2527
- name: Publish to NuGet
2628
shell: bash
2729
run: dotnet nuget push tcli.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate

.github/workflows/release.yml

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,34 @@ on:
88
jobs:
99
# Validate tag with proper regex since the check above is very limited.
1010
validate-tag:
11+
name: Validate tag semantic version
1112
runs-on: ubuntu-latest
13+
outputs:
14+
tag: ${{ steps.tag.outputs.tag }}
1215
steps:
13-
- uses: actions/checkout@v2
14-
- id: tag
15-
uses: dawidd6/action-get-tag@v1
16+
- name: Checkout ref that triggered workflow
17+
uses: actions/checkout@v4
18+
19+
- name: Ensure triggering ref is a tag
20+
id: tag
21+
uses: devops-actions/action-get-tag@v1.0.2
22+
1623
- id: regex-match
1724
uses: actions-ecosystem/action-regex-match@v2
1825
with:
1926
text: ${{ steps.tag.outputs.tag }}
20-
regex: '^([1-9][0-9]*|[0-9])\.([1-9][0-9]*|[0-9])\.([1-9][0-9]*|[0-9])$'
27+
regex: '^([1-9][0-9]*|0)\.([1-9][0-9]*|0)\.([1-9][0-9]*|0)$'
28+
2129
- id: fail-fast
2230
if: ${{ steps.regex-match.outputs.match == '' }}
23-
uses: actions/github-script@v3
31+
uses: actions/github-script@v7
2432
with:
2533
script: core.setFailed('Tag is invalid')
2634

2735
platform-binary:
36+
name: Build binaries for ${{ matrix.target }}
2837
needs: validate-tag
2938
if: github.event.base_ref == 'refs/heads/master'
30-
name: Create binary ${{ matrix.target }}
3139
runs-on: ${{ matrix.os }}
3240
strategy:
3341
matrix:
@@ -43,19 +51,24 @@ jobs:
4351
target: osx-x64
4452
os: macos-latest
4553
steps:
46-
- uses: actions/checkout@v2
47-
- uses: actions/setup-dotnet@v3
54+
- name: Checkout ref that triggered workflow
55+
uses: actions/checkout@v4
56+
57+
- name: Setup .NET
58+
uses: actions/setup-dotnet@v4
4859
with:
4960
dotnet-version: '7'
50-
- id: tag
51-
uses: dawidd6/action-get-tag@v1
61+
5262
- name: Install dependencies
5363
run: dotnet restore
5464

65+
- name: Setup Cargo/Rust
66+
uses: moonrepo/setup-rust@v1
67+
5568
- name: Build
5669
shell: bash
5770
run: |
58-
release_name="tcli-${{ steps.tag.outputs.tag }}-${{ matrix.target }}"
71+
release_name="tcli-${{ needs.validate-tag.outputs.tag }}-${{ matrix.target }}"
5972
dotnet publish ThunderstoreCLI/ThunderstoreCLI.csproj -c Release -r "${{ matrix.target }}" --self-contained true -f net7.0 -o "${release_name}"
6073
6174
if [ "${{ matrix.target }}" == "win-x64" ]; then
@@ -66,39 +79,44 @@ jobs:
6679
6780
rm -r ${release_name}
6881
69-
- name: Publish to GitHub
82+
- name: Add build artifacts to draft GitHub release
7083
uses: softprops/action-gh-release@v1
7184
with:
7285
files: "tcli*"
73-
name: "Thunderstore CLI ${{ steps.tag.outputs.tag }}"
86+
name: "Thunderstore CLI ${{ needs.validate-tag.outputs.tag }}"
7487
body_path: ${{ github.workspace }}/.github/RELEASE_TEMPLATE.md
7588
draft: true
7689
prerelease: ${{ startsWith(steps.tag.outputs.tag, '0.') }}
7790

7891
nupkg:
92+
name: Build NuGet Package
7993
needs: validate-tag
8094
if: github.event.base_ref == 'refs/heads/master'
81-
name: Create .nupkg
8295
runs-on: ubuntu-latest
8396
steps:
84-
- uses: actions/checkout@v2
85-
- uses: actions/setup-dotnet@v3
97+
- name: Checkout ref that triggered workflow
98+
uses: actions/checkout@v4
99+
100+
- name: Setup .NET
101+
uses: actions/setup-dotnet@v4
86102
with:
87103
dotnet-version: '7'
88-
- id: tag
89-
uses: dawidd6/action-get-tag@v1
104+
90105
- name: Install dependencies
91106
run: dotnet restore
92107

108+
- name: Setup Cargo/Rust
109+
uses: moonrepo/setup-rust@v1
110+
93111
- name: Build
94112
shell: bash
95113
run: dotnet pack ThunderstoreCLI/ThunderstoreCLI.csproj -c Release -o "." -p:EnableInstallers=false -p:PublishSelfContained=false -p:PublishSingleFile=false -p:PublishTrimmed=false -p:PublishReadyToRun=false
96114

97-
- name: Publish to GitHub
115+
- name: Add build artifacts to draft GitHub release
98116
uses: softprops/action-gh-release@v1
99117
with:
100118
files: "tcli*"
101-
name: "Thunderstore CLI ${{ steps.tag.outputs.tag }}"
119+
name: "Thunderstore CLI ${{ needs.validate-tag.outputs.tag }}"
102120
body_path: ${{ github.workspace }}/.github/RELEASE_TEMPLATE.md
103121
draft: true
104122
prerelease: ${{ startsWith(steps.tag.outputs.tag, '0.') }}

.github/workflows/test.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
11
name: Build & Test
22

3-
on: [push]
3+
on:
4+
# Trigger on pushes to the main branch
5+
push:
6+
branches: [ master ]
7+
# Trigger on any pull request
8+
pull_request:
49

510
jobs:
611
pre-commit:
712
name: Code style check
813
runs-on: ubuntu-latest
914
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-dotnet@v3
15+
- name: Checkout ref that triggered workflow
16+
uses: actions/checkout@v4
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
1220
with:
1321
dotnet-version: '7'
14-
- uses: actions/setup-python@v2
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v2
1525
with:
1626
python-version: '3.8'
17-
- name: Install pre-commit
27+
28+
- name: Install pre-commit framework
1829
run: curl https://pre-commit.com/install-local.py | python -
30+
1931
- name: Install dotnet-format
2032
run: dotnet tool install -g dotnet-format
33+
2134
- name: Run pre-commit
2235
run: ~/bin/pre-commit run --show-diff-on-failure --color=always --all-files
2336

@@ -30,19 +43,30 @@ jobs:
3043
env:
3144
OS: ${{ matrix.os }}
3245
steps:
33-
- uses: actions/checkout@v2
34-
- uses: actions/setup-dotnet@v3
46+
- name: Checkout ref that triggered workflow
47+
uses: actions/checkout@v4
48+
49+
- name: setup .NET
50+
uses: actions/setup-dotnet@v4
3551
with:
3652
dotnet-version: '7'
53+
54+
- name: Setup Cargo/Rust
55+
uses: moonrepo/setup-rust@v1
56+
3757
- name: Install dependencies
3858
run: dotnet restore
59+
3960
- name: Build
4061
run: dotnet build --configuration Release --no-restore
62+
4163
- name: Run xUnit tests
4264
run: dotnet test -p:EnableInstallers=false --collect:"XPlat Code Coverage"
65+
4366
- name: Upload coverage to Codecov
44-
uses: codecov/codecov-action@v2
67+
uses: codecov/codecov-action@v3
4568
with:
4669
directory: ./ThunderstoreCLI.Tests/TestResults/
4770
env_vars: OS
4871
fail_ci_if_error: true
72+
token: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# thunderstore-cli
22

3+
[![Build & Test](https://github.com/thunderstore-io/thunderstore-cli/actions/workflows/test.yml/badge.svg)](https://github.com/thunderstore-io/thunderstore-cli/actions/workflows/test.yml)
34
[![codecov](https://codecov.io/gh/thunderstore-io/thunderstore-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/thunderstore-io/thunderstore-cli)
5+
[![NuGet Package](https://img.shields.io/nuget/v/tcli)](https://www.nuget.org/packages/tcli)
6+
[![downloads](https://img.shields.io/nuget/dt/tcli)](https://www.nuget.org/packages/tcli)
47

58
Thunderstore CLI (just "TCLI" from here on) is a command line tool for building and uploading mod packages to
69
[Thunderstore](https://thunderstore.io/) mod database, and installing mods via the command line.

0 commit comments

Comments
 (0)