diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 8be9b6f..a9ab7ff 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -182,11 +182,15 @@ jobs: echo 'Artifact URL is ${{ steps.artifact-upload-step-id.artifact-url }}' echo 'Artifact SHA 256 is ${{ steps.artifact-upload-step-id.artifact-digest }}' upload: + outputs: + tag-name: ${{ steps.set-tag.outputs.tag }} # 设置一个输出标签。对外包露tag-name,值来自于当前job下steps下id叫set-tag的环境变量tag strategy: matrix: runs-on: [ubuntu-latest] # [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.runs-on }} steps: + - id: set-tag + run: echo "tag=release-$(TZ=+8 date '+%Y-%m-%d_%H_%M_%S')" >> $GITHUB_OUTPUT # 把变量输出到github的输出环境,上面的outputs就能获取到 - name: Create a File run: | echo "$(TZ=+8 date '+%Y%m%d%H%M%S') hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt @@ -202,6 +206,8 @@ jobs: needs: upload runs-on: ubuntu-latest steps: + - name: 获取跨job上游job的输出变量值 + run: echo "The tag from previous job is ${{ needs.upload.outputs.tag-name }}" - name: Download All Artifacts uses: actions/download-artifact@v3 #github公开版可以用v4 with: @@ -215,7 +221,7 @@ jobs: - run: ls -R my-artifact - name: 读取跨job文件中的变量 run: | - version=$(jq -r .version ./meta.json) + version=$(jq -r .version ./my-artifact/meta.json) echo "Version is $version #变量在$GITHUB_ENV中存放,可实现同一个steps可以共享" echo "VERSION=$version" >> $GITHUB_ENV - name: Use shared version @@ -224,7 +230,7 @@ jobs: run: | mkdir release # find all-artifacts -type f -exec cp {} release/ \; - find . -type f -exec cp {} release/ \; + find ./my-artifact -type f -exec cp {} release/ \; ls -lah ./release - name: Generate SHA-256 run: | @@ -250,7 +256,7 @@ jobs: # token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} # name: 发布名称。默认为标签名称 # tag_name: 标签名称。默认为github.ref_name - tag_name: dfsf + tag_name: ${{ needs.upload.outputs.tag-name }} with: files: | *.txt