-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrelease.yaml
More file actions
112 lines (97 loc) · 4.19 KB
/
release.yaml
File metadata and controls
112 lines (97 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Release
run-name: ${{ format('{0} {1}', inputs.is-dry-run && 'Dry-run' || 'Release', inputs.tag) }}
on:
workflow_dispatch:
inputs:
tag:
description: "Tag / Version number"
required: true
image-folder-name:
description: "Image folder name (for replacing image paths embedded in the README)"
required: false
default: "images"
is-dry-run:
description: "Dry-run (do not publish, only test build)"
type: boolean
permissions:
contents: write # required for pushing to the repository and creating releases
env:
changelog: CHANGELOG.md
thunderstore-config: thunderstore.toml
build-dir: build
artifact-content-type: application/zip
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
release:
name: ${{ format('{0} {1}', inputs.is-dry-run && 'Dry-run' || 'Release', inputs.tag) }}
runs-on: ubuntu-latest
steps:
- name: Check input tag format
run: |
if ! echo "${{ inputs.tag }}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error title=Invalid package version number::Version numbers must follow the Major.Minor.Patch format (e.g. 1.45.320)."
exit 1
fi
- name: Checkout files
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
lfs: true
- name: Rotate unreleased section in changelog
uses: baynezy/ChangeLogger.Action@6e3ad430f08e13698bb01027a13ba4349b0143cc
with:
tag: ${{ inputs.tag }}
log-path: ${{ env.changelog }}
- name: Rotate version in Thunderstore CLI config
run: |
sed -i 's/versionNumber = ".*"/versionNumber = "${{ inputs.tag }}"/' ${{ env.thunderstore-config }}
- name: Replace relative image paths with absolute paths in README
run: |
sed -i 's#](\(\./\)\?${{ inputs.image-folder-name }}/#](https://github.com/${{ github.event.repository.owner.login }}/${{ github.event.repository.name }}/raw/${{ github.event.repository.default_branch }}/${{ inputs.image-folder-name }}/#g' README.md
- name: Install Thunderstore CLI
run: dotnet tool install -g tcli
- name: Build package
run: |
tcli build
ARTIFACT_NAME=$(find "${{ env.build-dir }}" -type f -printf "%f\n")
echo "artifact-name=${ARTIFACT_NAME}" >> "$GITHUB_ENV"
echo "artifact-path=${{ env.build-dir }}/${ARTIFACT_NAME}" >> "$GITHUB_ENV"
- name: Upload artifact to workflow
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
with:
name: ${{ env.artifact-name }}
path: ${{ env.artifact-path }}
retention-days: 1
- name: Publish package
if: ${{ !inputs.is-dry-run }}
env:
TCLI_AUTH_TOKEN: ${{ secrets.TCLI_AUTH_TOKEN }}
run: tcli publish --file ${{ env.artifact-path }}
- name: Tag and push to repository
if: ${{ !inputs.is-dry-run }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ${{ env.changelog }} ${{ env.thunderstore-config }}
git commit --message "Release ${{ inputs.tag }}"
git tag ${{ inputs.tag }} --annotate --message "Release ${{ inputs.tag }}"
git push origin HEAD:${{ github.ref_name }} --tags
- name: Create release
id: release
if: ${{ !inputs.is-dry-run }}
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e
with:
release_name: ${{ inputs.tag }}
tag_name: ${{ inputs.tag }}
commitish: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact to release
if: ${{ !inputs.is-dry-run }}
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_name: ${{ env.artifact-name }}
asset_path: ${{ env.artifact-path }}
asset_content_type: ${{ env.artifact-content-type }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}