Skip to content

Commit 52f931e

Browse files
authored
Merge pull request #3297 from rintaro/workflow-rdar171530903
[workflow] Use environment variables for user inputs
2 parents 9d6e738 + 3e6cf7b commit 52f931e

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

.github/workflows/publish_release.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ jobs:
2626
# at the same time. If the release manager changes between users, update this condition.
2727
runs-on: ubuntu-latest
2828
steps:
29-
- run: |
30-
if [[ "${{ github.triggering_actor }}" != "rintaro" && "${{ github.triggering_actor }}" != "hamishknight" ]]; then
31-
echo "${{ github.triggering_actor }} is not allowed to create a release"
29+
- env:
30+
TRIGGERING_ACTOR: ${{ github.triggering_actor }}
31+
run: |
32+
if [[ "${TRIGGERING_ACTOR}" != "rintaro" && "${TRIGGERING_ACTOR}" != "hamishknight" ]]; then
33+
echo "${TRIGGERING_ACTOR} is not allowed to create a release"
3234
exit 1
3335
fi
3436
test:
@@ -53,20 +55,25 @@ jobs:
5355
steps:
5456
- name: Determine tag name
5557
id: swift_syntax_version
58+
env:
59+
INPUT_PRERELEASE: ${{ github.event.inputs.prerelease }}
60+
INPUT_SWIFT_SYNTAX_VERSION: ${{ github.event.inputs.swift_syntax_version }}
5661
run: |
57-
if [[ "${{ github.event.inputs.prerelease }}" == "false" ]]; then
58-
SWIFT_SYNTAX_VERSION="${{ github.event.inputs.swift_syntax_version }}"
62+
if [[ "${INPUT_PRERELEASE}" == "false" ]]; then
63+
SWIFT_SYNTAX_VERSION="${INPUT_SWIFT_SYNTAX_VERSION}"
5964
else
60-
SWIFT_SYNTAX_VERSION="${{ github.event.inputs.swift_syntax_version }}-prerelease-$(date +'%Y-%m-%d')"
65+
SWIFT_SYNTAX_VERSION="${INPUT_SWIFT_SYNTAX_VERSION}-prerelease-$(date +'%Y-%m-%d')"
6166
fi
6267
echo "Using swift-syntax version: $SWIFT_SYNTAX_VERSION"
6368
echo "swift_syntax_version=$SWIFT_SYNTAX_VERSION" >> "$GITHUB_OUTPUT"
6469
- name: Checkout repository
6570
uses: actions/checkout@v6
6671
- name: Tag release
72+
env:
73+
SWIFT_SYNTAX_VERSION: ${{ steps.swift_syntax_version.outputs.swift_syntax_version }}
6774
run: |
68-
git tag "${{ steps.swift_syntax_version.outputs.swift_syntax_version }}"
69-
git push origin "${{ steps.swift_syntax_version.outputs.swift_syntax_version }}"
75+
git tag "${SWIFT_SYNTAX_VERSION}"
76+
git push origin "${SWIFT_SYNTAX_VERSION}"
7077
create_release:
7178
name: Create prerelease on GitHub
7279
runs-on: ubuntu-latest
@@ -81,7 +88,8 @@ jobs:
8188
- name: Create release
8289
env:
8390
GH_TOKEN: ${{ github.token }}
91+
SWIFT_SYNTAX_VERSION: ${{ needs.create_tag.outputs.swift_syntax_version }}
8492
run: |
85-
gh release create "${{ needs.create_tag.outputs.swift_syntax_version }}" \
86-
--title "${{ needs.create_tag.outputs.swift_syntax_version }}" \
93+
gh release create "${SWIFT_SYNTAX_VERSION}" \
94+
--title "${SWIFT_SYNTAX_VERSION}" \
8795
--prerelease

0 commit comments

Comments
 (0)